Starting from:

$25

CS 372 Homework 2

CS372 Operating System

HW2

 

3.6 Describe the differences among short-term, medium-term, and longterm scheduling.

 

3.7  Describe the actions taken by a kernel to context-switch between processes.

 

3.8 Construct a process tree similar to Figure 3.9. To obtain process information for the UNIX or Linux system, use the command ps -ael. Use the command man ps to get more information about the ps command. The task manager onWindows systems does not provide the parent process id,yet the processmonitor tool available fromtechnet.microsoft.com provides a process tree tool.

 

3.9  What are the pid values? Run the following code to prove your guess.  Submit the result of the screen shot.

 

#include <sys/types.h

#include <stdio.h

#include <unistd.h

 

int main()

{

pid_t pid, pid1;

 

            pid = fork();

 

            if (pid<0){

                        printf(stderr, “fork failed”);

                        return 1;

            }

            else if (pid == 0){

                        pid1 = getpid();

                        printf(“child: pid = %d”, pid);

printf(“child: pid1 = %d”, pid1);

            }

            else {

                        pid1 = getpid();

                        printf(“parent: pid = %d”, pid);

printf(“parent: pid1 = %d”, pid1);

wait(NULL);

            }

            return 0;

}

More products