Lecture2 - CSCE 313: Introduction to Computer Systems...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
CSCE 313: Introduction to Computer Systems Spring 2011 Dr. Ronnie Ward
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Programs, Processes and Threads Chapters 2 and 3 in textbook Some slides adopted and modified from Dr. Bettati.
Background image of page 2
Process Management What is a process? How to control processes? How to allocate the available resources to the execution of the processes (scheduling) How to coordinate processes among themselves (synchronization) 2/14/12 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Program, Users, Processes Users interact with the computing system Programs are launched and executed, by users: Multiple users start the same program One users starts multiple times the same program Display all running processes: Windows: Task Manager -> Processes Unix: $ ps - e; lists information about every process now running. 2/14/12 4
Background image of page 4
Processes and Process Control Q: What is a process? Process as execution of a Program We can trace the execution of a process Process as minimal entity for resource allocation (for example memory). 2/14/12 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Memory Layout of Running Program 2/14/12 6
Background image of page 6
Execution Trace of Processes Two processes and a dispatcher dispatcher program A α β δ program B α α +1 α +2 α +3 α +4 α +5 α +6 α +7 α +8 α +9 α +10 α +11 β β +1 β +2 β +3 β +4 β +5 β +6 β +7 β +8 β +9 β +10 β +11 δ δ +1 δ +2 δ +3 δ +4 Trace of dispatcher Traces of processes A and B β β +1 β +2 β +3 β +4 δ δ +1 δ +2 δ +3 δ +4 α α +1 α +2 α +3 α +4 δ δ +1 δ +2 δ +3 δ +4 β +5 β +6 β +7 ... 2/14/12 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
States of a Process User view : A process is executing continuously In reality : Several processes compete for the CPU and other resources A process may be running : it holds the CPU and is executing : it is waiting for some I/O event to occur ready : it is waiting to get back on the CPU ready running blocked te rm ina te c re a pre e m pt dis pa t c h I/O   re q ue s t c o m ple te 2/14/12 8
Background image of page 8
Process Creation When is a process created ? Submission of a batch job User logs on Create process to provide service such as printing Spawned by existing processes How ? In UNIX: all processes created by fork() system call 2/14/12 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Process Creation Creation Load code and data into memory Create an empty call stack Initialize state to same as after a process switch Make the process ready to run Clone Stop current process and save state Make copy of current code, data, stack and OS state Make the process ready to run 2/14/12 10
Background image of page 10
Example: Vanilla Command Interpreter 2/14/12 11 c har c o m m a nd[MAX_C O MMAND_LENG TH]; do  {   c o m m a nd = re a d_c o m m a nd(s tdin);    if  ( fork()  != 0) {     /* parent */      if  (la s t_c ha r(c o m m and) != ‘&’) {        /* run in foreground, i.e. wait */ waitpid (-1, &s ta tus , . ..);     }   } else  {  /* child */ execve (c o m m a nd, . while  (s trc m p(c o m m a nd, “e xit”) != 0);  /* ?!? */
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Process Control Block Preempt Process A and store all relevant information.
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 53

Lecture2 - CSCE 313: Introduction to Computer Systems...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online