Presentation is loading. Please wait.

Presentation is loading. Please wait.

Processes and Threads Chapter 2 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.

Similar presentations


Presentation on theme: "Processes and Threads Chapter 2 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling."— Presentation transcript:

1 Processes and Threads Chapter 2 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling

2 What is a process? There is a subtle difference between the concepts of program and process –A process is a program in execution See p. 73 for a beautiful everyday analogy –It illustrates the notions of program, process, interrupt and pseudoparallelism.

3 Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential processes Only one program active at any instant

4 What causes process creation? System initialization –Foreground and background processes Execution of a process creation system –Through system calls – fork () in UNIX  User request to create a new process –The result of a double click in Windows Initiation of a batch job –On mainframes only

5 A stripped down shell with fork() while (TRUE) { /* repeat forever */ type_prompt( );/* display prompt */ read_command (command, parameters)/* input from terminal */ pid = fork(); /* fork off child process */ if (pid != 0) { /* Parent code */ waitpid( -1, &status, 0);/* wait for child to exit */ } else { /* Child code */ execve (command, parameters, 0);/* execute command */ }

6 What causes process termination? Normal exit (voluntary) –return 0; Error exit (voluntary) –Illegal instructions, division by zero, illegal memory access Fatal error (involuntary) –Incorrect program parameters Killed by another process (involuntary)

7 Process Hierarchies Parent creates a child process, child process may create its own process Forms a hierarchy –UNIX calls this a "process group" Windows has no concept of process hierarchy –All processes are created equal

8 Process tree A process group with root A –A created two child processes, B and C –B created three child processes, D, E, and F

9 Process States

10 Process Table There is a table entry for each process

11 Processes & Interrupts Low memory contains an interrupt vector for each I/O device. –It contains the address of the interrupt service procedure. When I/O completes, the CPU is interrupted –The PC, PSW & register contents of the process that is running at that moment are pushed onto the stack by the interrupt controller and the CPU executes the instruction at the address in the interrupt vector.


Download ppt "Processes and Threads Chapter 2 2.1 Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling."

Similar presentations


Ads by Google