OPS102 - Week 5 - Adi - ProcessManagement

docx

School

Seneca College *

*We aren’t endorsed by this school

Course

102

Subject

Information Systems

Date

Dec 6, 2023

Type

docx

Pages

21

Uploaded by DrQuail3570

Report
OPS102 – Week 5 – Process Management - Sample Lab Student Name: Aditya Mahesh Tambe Student ID: 171969223 Introduction Both Linux and Windows, as powerful operating systems, provides robust process management capabilities. Understanding how to manage processes is crucial for effectively utilizing the operating system. A process refers to an executing program or task, whether it is a system service, a user application, or a background utility. Here are some fundamental concepts related to process management: Processes and Process IDs (PIDs): Every process in Linux or Windows is assigned a unique identifier called a Process ID (PID). PIDs enable the system to track and manage processes effectively. You can view the PIDs of running processes using various commands and utilities. Process States : Processes can be in different states, such as running, sleeping, stopped, or terminated. Understanding these states helps in monitoring and controlling processes effectively. Commands like ps and top provide insights into process states. Process Ownership : Each process is associated with an owner, typically the user who initiated or owns the process. Process ownership is essential for managing permissions and access control. Process Hierarchy : processes follow a hierarchical structure. A process can create child processes, and those child processes can, in turn, spawn their own subprocesses. This hierarchical arrangement helps organize and manage related processes. Process Control : Linux provides various commands and tools to control processes. You can start, stop, pause, resume, or terminate processes using commands like kill, killall, pkill, and signals such as SIGSTOP and SIGCONT. Windows offers multiple methods to control processes. The Task Manager, a built-in Windows utility, allows you to view and manage running processes. It enables you to end processes, change process priorities, and analyze resource usage.
F oreground and Background Processes : Both Linux and windows allow executing processes either in the foreground or background. Foreground processes run directly in the terminal, while background processes operate independently, freeing up the terminal for other tasks. You can switch between foreground and background using commands like &, fg, and bg commands in Linux. In windows, Task Manager and PowerShell provide options to manage processes in both modes. Process Monitoring and Resource Usage : Monitoring the performance and resource usage of processes is essential for system administrators. In Linux, tools like top, htop, and ps provide real-time information on CPU usage, memory consumption, and other vital statistics. In Windows, Task Manager provides real-time information on CPU usage, memory consumption, disk activity, and network utilization. Performance Monitor (PerfMon) is a powerful tool for in-depth process monitoring. Activity 1: Monitoring Linux Processes with ps command Perform the following steps: 1. Make certain that you are logged into your Matrix account 2. Issue a Linux command to confirm that you are located in your home directory. 3. The ps _ command provides a list of processes that are running, or at least that were running at the time the command was called. Run the command ps in your terminal
What output you see, take a screenshot and paste below. Ans. With the ps command, I am able to see the total files and directories in my matrix account. 4. How many processes are currently running? What information is displayed for each process? Answer below. Ans. There are 0 process running in the matrix account because as a student login in we don’t have access, to see the foreground as well as background. 5. Use the ps command with the ‘-e’ option to display information about all processes in the system. Run the command ps -e
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
6. Analyze the output and identify the running processes on your system. Note the PID, TTY, and CMD columns. What do these column mean? PID stands for unique process ID
TTY stands for terminal type that the user is logged into. CMD stands for the name of the command that has been started or launched the process. 7. Use the 'ps' command with the '-f' option to display a full-format listing of the processes. Run the command ps -f 8. Examine the output, which provides detailed information about each process, including UID, PID, PPID, CPU%, MEM%, START, and CMD UID stands for the user who created or initiated the process and it identifies the owner of the process and helps in accessing the control and security for it. PID stands for unique numerical identifier assigned to each process, and allows us to interact with specific processes. PPID stands for parent process ID which indicates the PID of the parent process that spawned the current or working process, It demonstrates the process hierarchy. CPU% stands for the CPU usage and shows the percentage of CPU resources that process is currently using or utilizing. It helps in monitoring the usage of resource. 9. Use the 'ps' command with the '-l' option to display a long listing format of processes. Execute the following command: ps -l
10. Analyze the output and observe the columns displayed, including F, S, UID, PID, PPID, PRI, NI, ADDR, SZ, RSS, WCHAN, STAT, TTY, TIME, and CMD. F stands for flags and indicates different process status flags, whether the process is in foreground or in background. S stands for state which show the current state for the process is it running, stopped. UID stands for the user who created or initiated the process and it identifies the owner of the process and helps in accessing the control and security for it. PID stands for unique numerical identifier assigned to each process, and allows us to interact with specific processes. PPID stands for parent process ID which indicates the PID of the parent process that spawned the current or working process, It demonstrates the process hierarchy. PRI stands for the priority and prioritize the process according to its importance. NI stand Nice value which helps the CPU to prioritize the CPU queue. ADDR stands for the memory address and showing its location in the memory
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
SZ stands for the size of the process and includes the data RRS it represent the portion of memory used by the process that is currently in RAM WCHAN represent the waiting channel and displays the kernel function in the process and providing the insights into status. STAT stands for status and provides a compact representation of the process’s resource usage and current stage. TTY stands for terminal type that the user is logged into. TIME shows the time consumed by the process in DD format. CMD stands for the name of the command that has been started or launched the process. 11. Use the ' -u ' option followed by a username to display processes owned by that user. 12. Use the ' -p ' option followed by a process ID (PID) to display information about a specific process.
Activity 2: Monitoring Linux Processes with top command The top command is a powerful tool in Linux used to monitor and manage system resources in real-time. It provides a dynamic view of CPU usage, memory utilization, running processes, and other essential system metrics. In this activity, experiment with this command to understand resource usage. 1. Run the command top in your terminal. What output do you observe, below paste a screenshot of the terminal output?
2. Once the top command is running, you'll see a continuously updated display with various sections and columns.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
3. Explain what information the following columns give. PR Represents the scheduling priority of a process in the Linux operating system. A lower numerical value indicates higher priority, influencing CPU allocation. NI stand Nice value which helps the CPU to prioritize the CPU queue. VIRT Indicates the total virtual memory space used by a process, including both RAM and swap space, reflecting the memory it could potentially use. RES Represents the portion of virtual memory that is currently residing in physical RAM, indicating the actual memory usage by a process. CPU% stands for the CPU usage and shows the percentage of CPU resources that process is currently using or utilizing. It helps in monitoring the usage of resource. %MEM shows the percentage of physical RAM being used by the process in relation to the total available RAM.
TIME+ Reflects the cumulative CPU time used by the process since it started, including more detailed time granularity than the regular TIME field. 4. The top command provides interactive features to customize the display and perform actions. Press 'P' to sort processes by CPU usage, 'M' to sort by memory usage, and 'N' to sort by PID. 5. To exit the top command, simply press 'q'. This will close the top display and return you to the terminal prompt. Activity 3: Sending signals to processes In Linux processes, system admins can send signals to communicate with processes and request specific actions. Signals are software interrupts delivered to a process by the operating system
or another process. Signals allow processes to respond to various events, such as the termination of another process, user input, or changes in system conditions. Signals are identified by unique numbers, known as signal numbers. Each signal number corresponds to a specific event or action. Each signal has a default action associated with it, which determines what the process does when it receives that signal. Common default actions include termination, stopping, or ignoring the signal. Common Signals: Linux systems have a set of standard signals defined, each with its own signal number. Some commonly used signals include: SIGTERM (Signal 15): This is the default signal sent by the kill command to request a process to terminate gracefully. SIGKILL (Signal 9): This signal immediately terminates a process. It cannot be caught or ignored. SIGSTOP (Signal 19): This signal pauses a process, suspending its execution until a SIGCONT signal is received. SIGCONT (Signal 18): This signal resumes the execution of a process that was previously stopped by a SIGSTOP signal. SIGHUP (Signal 1): This signal is typically sent to inform a process that the controlling terminal has been disconnected. Signals can be sent to processes using the kill command. Perform the following steps: 1. I ssue the following command: sleep 500 The "sleep" command in Linux is a utility that allows you to pause the execution of a script or command for a specified amount of time. We will be using this command to simulate the behavior of a "long-running" process. This process will run for 500 seconds , and is forcing the user to wait until this process finishes. A process that is running in the terminal is referred to as a foreground process . 2. Run the command: ps 3. Note the process id of sleep command. 4. Run the command: kill PID (replace PID with process id)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
By default, the kill command sends the SIGTERM signal (signal number 15) to the process, requesting it to terminate gracefully. However, you can specify a different signal using the -s option followed by the signal number or signal name. What output you see? Paste a screensot of the output below. Run the command sleep 500 another time and this time send the SIGKILL singnal to this process. What output you see? Paste a screensot of the output below. 5. What difference you noticed in SIGTERM and SIGKILL singals? Activity 4: Foreground and background processes 1. Again ssue the following command: sleep 500 The Unix/Linux system is designed to allow users to send preemptive signals to manage those processes. 2. Press the following key combination to interrupt the process running on the terminal: ctrl-z. This sends a SIGSTOP signal to the process. 3. You should see output similar to what is displayed below:
4. This indicates that this process has been placed into the background . This is useful in order to " free-up " the terminal to run other Linux commands 5. Issue the following Linux command: jobs You should see the following output: This display indicates that this process (that is now in the background) has stopped . In other words, the sleep command is NOT counting-down to zero to terminate. 6. The plus sign "+" indicates the most recent process placed into the background.
7. Sometimes you would like to run the process you stopped in the background. You can use bg command without arguments to run in background the most recent process that was stopped. 8. Run the command: bg 9. Issue the command: jobs 10. You should see the following output similar to what was displayed above 11. The & sign indicates that the process is now running in the backlground. 12. You can also bring this process to foreground using fg command. 13. Issue the command fg. This will make the sleep process run in foreground. Activity 5: Managing Windows Processes with PowerShell Mostly Task Manager application is used for managing processes on Windows. However, Windows PowerShell does provide some commands for process management. The main command used to get information about process is called ‘ Get-Process ’. In the following tasks use this command in Windows PowerShell to get information about the process. 1. Run the Get-Process command in PowerShell and explain the output
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
2. Explain the meaning of column headers of the information output by this command 3. To get information about specific process you can use the syntax Get-Process <process-name> . For example, to get information about firefox process you can run command Get-Process firefox . Run this command to get information about a process of your choosing and show the screenshot below. 4. Using this same command describe with example how you can get information about multiple processes 5. To stop a process you can use Stop-Process command with syntax Stop-Process <process-name> . In this task use this command to stop some process and show the screenshot below 6. There are two other commands of this class to manage processes. These commands are Wait-Process and Debug-Process . Search and read about these commands and provide examples.
Further Practice Questions. Answer the following questions based on your knowledge of process management in Linux. 1. What is a process in Linux? Answer: A process in linux is a running instance of program or task that OS manages. It represents an executable program along with its associated resources and data. It plays a fundamental role in multitasking and resource management withing the Linux OS. 2. Name three different states a process can be in, and briefly describe each state. a) State 1: R)unning: Description: (R)unning: currently using the CPU b) State 2: (S)leeping Description: (S)leeping: waiting in queue to use the CPU c) State 3: s(T)opped Description: s(T)opped: stopped (but not terminated), either by user or other process
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
3. Which command is used to list processes in Linux? Provide an example of its usage. Command: Example: top command 4. Explain the meaning of the following columns displayed by the ps command: a) PID: PID stands for unique numerical identifier assigned to each process, and allows us to interact with specific processes. b) CPU% stands for the CPU usage and shows the percentage of CPU resources that process is currently using or utilizing. It helps in monitoring the usage of resource. c)%MEM shows the percentage of physical RAM being used by the process in relation to the total available RAM. 5. How can you terminate a process in Linux? Describe two different methods. Method 1: The kill command kills a single process at a time with the specified process id or job number. Method 2: The pkill command allows you to terminate processes by their name rather than PID. 6. What is the purpose of the top command in Linux? How can you sort processes using top?
Purpose of top: The purpose of the "top" command in Linux is to provide real-time monitoring of system processes, resource usage, and system performance. Sorting processes in top: once you are in top command in the task manager of the linux in easy words to say, then just press S and it will sort the process alphabetically 7. Why is it important to exercise caution when terminating processes in Linux? Explain briefly. System Stability: Stopping critical system processes can make your computer unstable, causing it to crash or become unusable. Data Loss: If you forcefully end a program, you might lose any unsaved work, especially in programs like text editors or databases that handle important data. Interrupted Tasks: Terminating a process can leave things in a messy state, potentially causing problems down the road. Unpredictable Consequences: Some processes rely on others. Shutting one down without knowing its connections can lead to unexpected issues. Security Concerns: Stopping processes improperly can create security holes or give unauthorized access to your system. 8. Briefly explain the difference between the kill and killall commands in Linux. kill: Think of it like targeting a specific person in a crowd by knowing their unique ID. "kill" stops a process by specifying its ID (PID), like stopping a particular person in a group. killall: Imagine stopping everyone in a group who has the same name. "killall" stops processes by their names, so if you say "killall firefox," it will stop all processes with the name "firefox," like stopping everyone named "firefox" in a crowd. 9. True or False: Terminating a process with SIGKILL allows it to perform cleanup operations before termination. Answer: False 10. Name two signals that can be sent to a process using the kill command, and briefly describe their effects. Signal 1: Effect: Effect: Think of SIGTERM as a polite request to a process to stop what it's doing and exit. It's like asking nicely, "Could you please finish up your work and leave the
room?" When a process receives SIGTERM, it has the opportunity to finish its tasks, save data, and then exit in an organized manner. This signal is used when you want a process to stop, but not abruptly. Signal 2: Effect: SIGKILL is like a command that says, "Stop right now, no questions asked!" It forcefully and instantly terminates a process without any chance for the process to tidy up or save its work. It's used in situations where a process is misbehaving, stuck, or needs to be terminated urgently. However, it's the equivalent of pulling the plug and doesn't allow for a graceful exit.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help