NAME: Lab 3 Process Management ITSC205: Operating Systems Internals $8 SAIT Table of Contents Lab Outcome(s)..... Reading Introduction. 1.0 Trace Processes 2.0 PROC - Pseudo File System ...... 3.0 Process
System Calls............. 4.0 Processes and Signals handling... 5.0 Extract Processes info from PROC...... 6.0 Inter-Process Communication (IPC)........ Labs must be submitted by the due date for full credit. After due date late submissions will receive a grade of zero (0). EVALUATION: Trace Processes Explore PROC - Pseudo File system structure Analyze and modify process System Calls I certify that the work submitted in this assignment is my own and that it has not been taken in whole or in part from any other source. I understand that the penalty for plagiarism will include a grade of zero (0) for this assignment plus disciplinary action in accordance with SAIT policies. Signature: Run and analyze process and Signals Handling Extract Process Information from Proc Inter-Process Communication TOTAL MARK SAIT 12 10 15 15 10 20 82 For more information, contact: Director, Centre for Instructional Technology and Development Southern Alberta Institute of Technology 1301 16 Ave. N.W., Calgary, AB T2M OL4 © 2024, Southern Alberta Institute of Technology. All rights reserved. This publication and materials herein are protected by applicable intellectual property laws. Unauthorized reproduction and distribution of this publication in whole or part is prohibited. .2 .2 .3 .3 ..5 .7 .9 .11 Lab Outcome(s) ● Trace processes running on Linux systems Apply system calls to create and terminate processes ● Run and modify c programs to analyze processes system calls Send signals to processes using Linux utilities and system calls. Reading Textbook chapter 3, sections 3.3.1 Process Creation and 3.3.2 Process Termination. Chapter 20 (Linux system ) section 20.4 Process Management SAIT Introduction A process is a program in execution. A Process requires system resources to complete its jobs such as: CPU time, memory space (memory areas to store image (executable) and to store global variables and stack for local variables and functions arguments), open files (file descriptor) and other handles. In UNIX/Linux operating systems processes stablish parent /child relationship. Processes can be in different states such as: Running on CPU or waiting for resources in a specific queue. A signal can be sent to a process to suspend it, terminate it or change its behaviour. To find information about signals use the command: info signal To create or clone a process UNIX/Linux operating systems implements fork( ) system call which generates an integer value to differentiate between a parent and child process (value=0). While the child implements exec() system call to execute the program, the parent will invoke the system call wait() to wait for the child to complete its job -(wait(&childPID) waits on child PID). After child process completes its job the signal (SIGCHLD) is sent to the parent process which will invoke the wait() or waitpid() system call and releases resources used by child process. If the parent does not exist the child process may become an orphan (child of init process or a thread) or a zombie that will hold resources affecting system performance. In this lab you will explore processes data structure within PROC pseudo-file system and use C program to extract processes info from PROC. You will implement parent/child processes system calls. Processes communicate within the same machine via techniques such as: pipes, share memory, remote procedure calls (RCP). Processes locate in different machines such as client/server architecture models implements named pipes and sockets to communicate process between client and server. In this Lab you will implement socket technique and analyze code and results. 2 ITSC205: Lab 3 2024, Southern Alberta Institute of Technology SAIT 1.0 Trace Processes Unix/Linux systems support many utilities/commands that can be used to manage processes. ps and top commands are common commands to manage processes. Use Linux commands to manage processes and demonstrate the following: /12 1. (3 points) Create a new process, suspend the process and identify the process state 2. (3 points) Create a Zombie process 3. (3 points) Open a second terminal and use the respective commands to display ONLY the properties such as: process name(cmd), pid, ppid and status of this process 4. (3 points) Open a new terminal, identify the zombie process ID and terminate the process 2.0 /PROC pseudo file-system Structure The /proc pseudo file-system is the root source of information about the processes within a GNU/Linux system. Within /proc directory, you'll find a set of directories with numbered filenames. These numbers represent the process IDs (pids) of active processes within the system. /10 Each pid directory presents a hierarchy of information about that process (process data structure) including the command line that started it, a symbolic link to the root file system, a symbolic link to the directory (current working directory) where the process was started, and other process attributes and configurations. Use man proc command for more information. ITSC205: Lab 3 2024, Southern Alberta Institute of Technology Under /proc directory the directories identify with numbers represent the PID of processes running in the system. These directories are the PCB (Process Control Block) of the processes 1. (5 points) Use the respective command to identify the PID of any process in the system Use /proc psudo file system to access PCB(info about the process). Explore the a. attributes of the process. Edit the file called status and demonstrate the following: a. Process state b. PID and PPID c. Threads are running in this process d. Explain the context switch values of this process 4. (5 points ) Use man proc. Explore /proc/pid information. Demonstrate how to use Linux manual to find the following information: a. Limits b. fd (File Descriptor) c. environ d. stack e. Use man proc and explore /proc/sys/kernel to find and briefly describe the purpose of pid_max file located 4 ITSC205: Lab 3 SAIT 2024, Southern Alberta Institute of Technology