DOC PREVIEW
UMD CMSC 412 - Operating Systems

This preview shows page 1-2-3-22-23-24-45-46-47 out of 47 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 47 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 47 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 47 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 47 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 47 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 47 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 47 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 47 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 47 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 47 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

3.1Silberschatz, Galvin and Gagne ©2005Operating System ConceptsCSMC 412CSMC 412Operating SystemsProf. Ashok K Agrawala© 2006 Ashok AgrawalaSet 33.2Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcessesProcesses Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems3.3Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcess ConceptProcess Concept An operating system executes a variety of programs:z Batch system – jobsz Time-shared systems – user programs or tasks Textbook uses the terms job and process almost interchangeably Process – a program in execution; process execution must progress in sequential fashion A process includes:z program counter z stackz data section3.4Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcess in MemoryProcess in Memory3.5Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcess StateProcess State As a process executes, it changes statez new: The process is being createdz running: Instructions are being executedz waiting: The process is waiting for some event to occurz ready: The process is waiting to be assigned to a processz terminated: The process has finished execution3.6Silberschatz, Galvin and Gagne ©2005Operating System ConceptsDiagram of Process StateDiagram of Process State3.7Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcess Control Block (PCB)Process Control Block (PCB)Information associated with each process Process state Program counter CPU registers CPU scheduling information Memory-management information Accounting information I/O status information3.8Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcess Control Block (PCB)Process Control Block (PCB)3.9Silberschatz, Galvin and Gagne ©2005Operating System ConceptsCPU Switch From Process to ProcessCPU Switch From Process to Process3.10Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcess Scheduling QueuesProcess Scheduling Queues Job queue – set of all processes in the system Ready queue – set of all processes residing in main memory, ready and waiting to execute Device queues – set of processes waiting for an I/O device Process migration between the various queues3.11Silberschatz, Galvin and Gagne ©2005Operating System ConceptsActive Processes in LinuxActive Processes in Linux3.12Silberschatz, Galvin and Gagne ©2005Operating System ConceptsReady Queue And Various I/O Device QueuesReady Queue And Various I/O Device Queues3.13Silberschatz, Galvin and Gagne ©2005Operating System ConceptsRepresentation of Process SchedulingRepresentation of Process Scheduling3.14Silberschatz, Galvin and Gagne ©2005Operating System ConceptsSchedulersSchedulers Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU3.15Silberschatz, Galvin and Gagne ©2005Operating System ConceptsAddition of Medium Term SchedulingAddition of Medium Term Scheduling3.16Silberschatz, Galvin and Gagne ©2005Operating System ConceptsSchedulers (Cont.)Schedulers (Cont.) Short-term scheduler is invoked very frequently (milliseconds) ⇒(must be fast) Long-term scheduler is invoked very infrequently (seconds, minutes) ⇒ (may be slow) The long-term scheduler controls the degree of multiprogramming Processes can be described as either:z I/O-bound process – spends more time doing I/O than computations, many short CPU burstsz CPU-bound process – spends more time doing computations; few very long CPU bursts3.17Silberschatz, Galvin and Gagne ©2005Operating System ConceptsContext SwitchContext Switch When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process Context-switch time is overhead; the system does no useful work while switching Time dependent on hardware support3.18Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcess CreationProcess Creation Parent process create children processes, which, in turn create other processes, forming a tree of processes Resource sharingz Parent and children share all resourcesz Children share subset of parent’s resourcesz Parent and child share no resources Executionz Parent and children execute concurrentlyz Parent waits until children terminate3.19Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcess Creation (Cont.)Process Creation (Cont.) Address spacez Child duplicate of parentz Child has a program loaded into it UNIX examplesz fork system call creates new processz exec system call used after a fork to replace the process’memory space with a new program3.20Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcess Tree for Solaris systemProcess Tree for Solaris system3.21Silberschatz, Galvin and Gagne ©2005Operating System ConceptsC Program Forking Separate ProcessC Program Forking Separate Process#include <stdio.h>#include <unistd.h>int main(int argc, char *argv[]){int pid;/* fork another process */pid = fork();if (pid < 0) { /* error occurred */fprintf(stderr, "Fork Failed");exit(-1);}else if (pid == 0) { /* child process */execlp("/bin/ls","ls",NULL);}else { /* parent process *//* parent will wait for the child to complete */wait(NULL);printf("Child Complete");exit(0);}}3.22Silberschatz, Galvin and Gagne ©2005Operating System ConceptsParent and Child ProcessesParent and Child Processes3.23Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcesses Tree on a UNIX SystemProcesses Tree on a UNIX System3.24Silberschatz, Galvin and Gagne ©2005Operating System ConceptsProcess TerminationProcess Termination Process executes last statement and asks the operating system todecide it (exit)z Output data from child to parent (via wait)z Process’ resources are deallocated by operating system Parent may terminate execution of children processes (abort)z Child has exceeded allocated resourcesz Task assigned to child is no longer requiredz If parent is exiting Some operating system do not allow child to continue if its parent terminates– All children terminated - cascading termination3.25Silberschatz, Galvin and Gagne ©2005Operating System ConceptsCooperating


View Full Document

UMD CMSC 412 - Operating Systems

Documents in this Course
Security

Security

65 pages

Deadlocks

Deadlocks

22 pages

Set 2

Set 2

70 pages

Project 2

Project 2

21 pages

Load more
Download Operating Systems
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Operating Systems and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Operating Systems 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?