DOC PREVIEW
UB CSE 421 - The Process Model

This preview shows page 1-2-17-18-19-35-36 out of 36 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 36 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 36 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 36 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 36 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 36 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 36 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 36 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 36 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

The Process ModelTopicsA View of Operating System ServicesTraditional UNIX System StructureSystem Call ImplementationAPI – System Call – OS RelationshipStandard C Library ExampleProcesses The Process ModelWhat is a process?Process in MemoryProcess creationTermination of a processProcess controlProcess control (contd.)Process Creation (contd.)Process Creation (Contd.)Slide 17C Program Forking Separate ProcessProcess Terminationfork and execExampleVersions of execProcess HierarchiesA tree of processes on a typical SolarisProcess StatesA five-state process modelState Transition Diagram (1)Process suspensionProcess suspension (contd.)State Transition Diagram (2)Implementation of ProcessesProcess Control Block (PCB)Slide 33CPU Switch From Process to ProcessContext SwitchSummaryPage 1The Process ModelPage 2Topics•Review system call•Introduce the process model–To introduce the notion of a process -- a program in execution, which forms the basis of all computation–To describe the various features of processes, including scheduling, creation and termination, and communication–To describe communication in client-server systemsPage 3A View of Operating System ServicesPage 4Traditional UNIX System StructurePage 5System Call Implementation•Typically, a number associated with each system call–System-call interface maintains a table indexed according to these numbers•The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values•The caller need know nothing about how the system call is implemented–Just needs to obey API and understand what OS will do as a result call–Most details of OS interface hidden from programmer by API •Managed by run-time support library (set of functions built into libraries included with compiler)Page 6API – System Call – OS RelationshipPage 7Standard C Library Example•C program invoking printf() library call, which calls write() system callPage 8ProcessesThe Process Model•Multiprogramming of four programs•Conceptual model of 4 independent, sequential processes•Only one program active at any instantPage 9What is a process?•A process is simply a program in execution: an instance of a program execution.•Unit of work individually schedulable by an operating system.•A process includes:–program counter –stack–data section•OS keeps track of all the active processes and allocates system resources to them according to policies devised to meet design performance objectives.•To meet process requirements OS must maintain many data structures efficiently.•The process abstraction is a fundamental OS means for management of concurrent program execution. Example: instances of process co-existing.Page 10Process in MemoryPage 11Process creation•Four common events that lead to a process creation are:1) When a new batch-job is presented for execution.2) When an interactive user logs in / system initialization.3) When OS needs to perform an operation (usually IO) on behalf of a user process, concurrently with that process.4) To exploit parallelism an user process can spawn a number of processes.Page 12Termination of a process•Normal completion, time limit exceeded, memory unavailable•Bounds violation, protection error, arithmetic error, invalid instruction•IO failure, Operator intervention, parent termination, parent request, killed by another process•A number of other conditions are possible. •Segmentation fault : usually happens when you try write/read into/from a non-existent array/structure/object component. Or access a pointer to a dynamic data before creating it. (new etc.)•Bus error: Related to function call and return. You have messed up the stack where the return address or parameters are stored.Page 13Process control•Process creation in unix is by means of the system call fork(). •OS in response to a fork() call:–Allocate slot in the process table for new process.–Assigns unique pid to the new process..–Makes a copy of the process image, except for the shared memory.–both child and parent are executing the same code following fork()–Move child process to Ready queue. –it returns pid of the child to the parent, and a zero value to the child.Page 14Process control (contd.)•All the above are done in the kernel mode in the process context. When the kernel completes these it does one of the following as a part of the dispatcher:–Stay in the parent process. Control returns to the user mode at the point of the fork call of the parent.–Transfer control to the child process. The child process begins executing at the same point in the code as the parent, at the return from the fork call.–Transfer control another process leaving both parent and child in the Ready state.Page 15Process Creation (contd.)•Parent process create children processes, which, in turn create other processes, forming a tree of processes•Generally, process identified and managed via a process identifier (pid)•Resource sharing–Parent and children share all resources–Children share subset of parent’s resources–Parent and child share no resources•Execution–Parent and children execute concurrently–Parent waits until children terminatePage 16Process Creation (Contd.)•Address space–Child duplicate of parent–Child has a program loaded into it•UNIX examples–fork system call creates new process–exec system call used after a fork to replace the process’ memory space with a new programPage 17Process Creation (contd.)Page 18C Program Forking Separate Processint main() {int retVal;/* fork another process */retVal = fork();if (retVal < 0) { /* error occurred */fprintf(stderr, "Fork Failed");exit(-1);}else if (retVal == 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);} }Page 19Process Termination•Process executes last statement and asks the operating system to delete it (exit)–Output data from child to parent (via wait)–Process’ resources are deallocated by operating system•Parent may terminate execution of children processes (abort)–Child has exceeded allocated resources–Task assigned to child is no longer required–If parent is exiting•Some operating system do not allow child to continue if its parent terminates–All children terminated - cascading terminationPage 20fork and exec•Child


View Full Document

UB CSE 421 - The Process Model

Documents in this Course
Security

Security

28 pages

Threads

Threads

24 pages

Security

Security

20 pages

Security

Security

52 pages

Security

Security

20 pages

Load more
Download The Process Model
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 The Process Model 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 The Process Model 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?