DOC PREVIEW
UB CSE 321 - ProcSept9

This preview shows page 1-2-3-4-5-6 out of 17 pages.

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

Unformatted text preview:

Slide 1Slide 2Traditional UNIX System StructureSystem CallAPI – System Call – Operating system RelationshipStandard C Library ExampleWhat is a process?Process in MemoryProcess controlProcess control (contd.)Process Creation (contd.)Process Creation (Contd.)Process Creation (contd.)A five-state process modelState Transition DiagramProcess creation - ExampleSystem Calls For Process Management and File ManagementB I N A R A M A M U R T H YB I N A @ B U F FA L O. E D UU N I V E R S I T Y AT B U F FA L OSystem Structure and Process Model01/13/20191Traditional unix structureSystem callStandard C libraries01/13/20192Page 3Traditional UNIX System Structure01/13/201901/13/20194System Call There are 11 steps in making the system call read (fd, buffer, nbytes)Page 5API – System Call – Operating system Relationship01/13/2019Page 6Standard C Library ExampleC program invoking printf() library call, which calls write() system call01/13/2019Page 7What 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 (OS).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.01/13/2019Page 8Process in Memory01/13/2019Page 9Process 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.01/13/2019Page 10Process 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.01/13/2019Page 11Process 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 terminate01/13/2019Page 12Process 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 program01/13/2019Page 13Process Creation (contd.)01/13/2019Page 14A five-state process modelFive states: New, Ready, Running, Blocked, ExitNew : A process has been created but has not yet been admitted to the pool of executable processes.Ready : Processes that are prepared to run if given an opportunity. That is, they are not waiting on anything except the CPU availability.Running: The process that is currently being executed. (Assume single processor for simplicity.)Blocked : A process that cannot execute until a specified event such as an IO completion occurs.Exit: A process that has been released by OS either after normal termination or after abnormal termination (error).01/13/2019Page 15State Transition Diagram NEWREADYRUNN INGBLOCKEDEXITAdmitDispatchTime-outReleaseEvent WaitEvent OccursThink of the conditions under which state transitions may take place.01/13/2019Page 16Process creation - Examplemain () { int pid; cout << “ just one process so far”<<endl; pid = fork(); if (pid == 0) cout <<“I am the child “<< endl; else if (pid > 0) cout <<“I am the parent”<< endl; else cout << “fork failed”<< endl;}01/13/201901/13/201917System Calls For Process Management and File


View Full Document

UB CSE 321 - ProcSept9

Documents in this Course
Anomaly1

Anomaly1

48 pages

LecSept2

LecSept2

30 pages

CRCNov23

CRCNov23

14 pages

Load more
Download ProcSept9
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 ProcSept9 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 ProcSept9 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?