DOC PREVIEW
UB CSE 421 - Unix Process Control

This preview shows page 1-2-21-22 out of 22 pages.

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

Unformatted text preview:

Unix Process ControlProcess images in virtual memoryCreation of a processProcess InterruptionUnix system VUNIX SVR4 Process StatesUNIX Process State DiagramProcess and Context SwitchingProcess and Context Switching (contd.)Process and Context Switching (contd.)Process and kernel contextU areaProcess ContextUNIX Process ImageUNIX Process ImageProcess controlProcess control (contd.)UNIX Process CreationUNIX System ProcessesProcess creation - Examplefork and execExample3/9/2003 B.Ramamurthy 1Unix Process ControlB.Ramamurthy3/9/2003 B.Ramamurthy 2Process images in virtual memory3/9/2003 B.Ramamurthy 3Creation of a processAssign a unique pid to the new process.Allocate space for all the elements of the process image. How much?The process control block is initialized. Inherit info from parent.The appropriate linkages are set: for scheduling, state queues..Create and initialize other data structures.3/9/2003 B.Ramamurthy 4Process InterruptionTwo kinds of process interruptions: interruptand trap.Interrupt: Caused by some event external to and asynchronous to the currently running process, such as completion of IO.Trap : Error or exception condition generated within the currently running process. Ex: illegal access to a file, arithmetic exception.Supervisor call: explicit interruption.3/9/2003 B.Ramamurthy 5Unix system VAll user processes in the system have as root ancestor a process called init. When a new interactive user logs onto the system, initcreates a user process, subsequently this user process can create child processes and so on. init is created at the boot-time.Process states : User running , kernel running, Ready in memory, sleeping in memory (blocked), Ready swapped (ready-suspended), sleeping swapped (blocked-suspended), created (new), zombie , preempted (used in real-time scheduling).3/9/2003 B.Ramamurthy 6UNIX SVR4 Process StatesSimilar to our 7 state model2 running states: User and Kernel transitions to other states (blocked, ready) must come from kernel runningSleeping states (in memory, or swapped) correspond to our blocking statesA preempted state is distinguished from the ready state (but they form 1 queue)Preemption can occur only when a process is about to move from kernel to user mode3/9/2003 B.Ramamurthy 7UNIX Process State Diagram3/9/2003 B.Ramamurthy 8Process and Context Switching Clock interrupt: The OS determines if the time slice of the currently running process is over, then switches it to Ready state, and dispatches another from Ready queue. “Process switch”Memory fault: (Page fault) A page fault occurs when the requested program page is not in the main memory. OS (page fault handler) brings in the page requested, resumes faulted process.IO Interrupt : OS determines what IO action occurred and takes appropriate action.3/9/2003 B.Ramamurthy 9Process and Context Switching (contd.)How many context switch occurs per process switch?Typically 1 Process switch : 100 context switchesProcess switch of more expensive than context switch.Read more on this.This factor is very important for many system design projects.3/9/2003 B.Ramamurthy 10Process and Context Switching (contd.)Process switch: A transition between two memory-resident processes in a multiprogramming environment. Context switch: Changing context from a executing program to an Interrupt Service Routine (ISR). Part of the context that will be modified by the ISR needs to be saved. This required context is saved and restored by hardware as specified by the ISR.3/9/2003 B.Ramamurthy 11Process and kernel contextUser modeApplication pgmssystem callskernel tasksinterrupt servicesKernel acts on behalf of userprocess contextkernelmodekernel context3/9/2003 B.Ramamurthy 12U area Process control blockPointer to proc structureSignal handlers related informationMemory management informationOpen file descriptorVnodes of the current directoryCPU usage statsPer process kernel stack3/9/2003 B.Ramamurthy 13Process ContextUser address space,Control information : u area (accessed only by the running process) and process table entry (or proc area, accessed by the kernel)Credentials : UID, GID etc.Environment variables : inherited from the parent3/9/2003 B.Ramamurthy 14UNIX Process ImageUser-level context Process Text (ie: code: read-only) Process Data User Stack (calls/returns in user mode)  Shared memory (for IPC) only one physical copy exists but, with virtual memory, it appears as it is in the process’s address spaceRegister context3/9/2003 B.Ramamurthy 15UNIX Process ImageSystem-level context Process table entry  the actual entry concerning this process in the Process Table maintained by OS Process state, UID, PID, priority, event awaiting, signals sent, pointers to memory holding text, data... U (user) area additional process info needed by the kernel when executing in the context of this process effective UID, timers, limit fields, files in use ... Kernel stack (calls/returns in kernel mode) Per Process Region Table (used by memory manager)3/9/2003 B.Ramamurthy 16Process controlProcess 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. Makes a copy of the process image, except for the shared memory. Move child process to Ready queue.  it returns pid of the child to the parent, and a zero value to the child.3/9/2003 B.Ramamurthy 17Process 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.3/9/2003 B.Ramamurthy 18UNIX Process CreationEvery process, except process 0, is created by the fork() system call fork() allocates entry in process table and assigns a unique PID to the child process child gets a copy of process image of parent: both child and parent are executing the same code following fork() but fork() returns the PID of the child to the parent process and returns 0 to the child process3/9/2003 B.Ramamurthy 19UNIX System ProcessesProcess 0 is created at boot time and


View Full Document

UB CSE 421 - Unix Process Control

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 Unix Process Control
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 Unix Process Control 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 Unix Process Control 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?