DOC PREVIEW
CORNELL CS 414 - UNIX Process Creation

This preview shows page 1-2-3-21-22-23-43-44-45 out of 45 pages.

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

Unformatted text preview:

UNIX Process CreationUNIX System ProcessesUNIX Process ImageSlide 4Process CharacteristicsMultithreading vs. Single threadingThreadsSingle Threaded and Multithreaded Process ModelsBenefits of Threads vs ProcessesBenefits of ThreadsApplication benefits of threadsSlide 12Threads StatesUser-Level Threads (ULT)Threads libraryKernel Activity for ULTsAdvantages and inconveniences of ULTKernel-Level Threads (KLT)Advantages and inconveniences of KLTCombined ULT/KLT ApproachesSolarisPowerPoint PresentationSolaris: versatilitySolaris: user-level thread executionSolaris: user-level thread statesDecomposition of user-level Active stateSolaris: Lightweight Process StatesOperating System Control StructuresProcess images in virtual memoryLocation of the Process ImageProcess Control BlockPCB Process IdentificationPCB Processor State InformationPCB Process Control InformationExecution ModesCPU Context SwitchContext Switching Basic StepsProcess SchedulingScheduling QueuesReady and I/O Device QueuesProcess Scheduling Queueing DiagramSchedulersShort-term Scheduler DispatcherLong-term SchedulerThe need for swapping1UNIX Process CreationUNIX Process CreationEvery 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 the parent process image  Both child and parent are executing the same code following fork() Need to invoke execve to load new binary filefork() returns the PID of the child to the parent process and returns 0 to the child process2UNIX System ProcessesUNIX System ProcessesProcess 0 is created at boot time and becomes the “swapper” after forking process 1 (the INIT process)When a user logs in, process 1 creates a process for that user3UNIX Process ImageUNIX Process ImageUser-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 spaceRegister context4UNIX Process ImageUNIX Process ImageSystem-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)5Process CharacteristicsProcess CharacteristicsThe two characteristics are treated independently by some recent OSThe unit of dispatching is usually referred to a thread or a lightweight processThe unit of resource ownership is usually referred to as a process or task6Multithreading vs. Single threadingMultithreading vs. Single threadingMultithreading: when the OS supports multiple threads of execution within a single processSingle threading: when the OS does not recognize the concept of threadMS-DOS support a single user process and a single threadUNIX supports multiple user processes but only supports one thread per processSolaris supports multiple threads7ThreadsThreadsHas an execution state (running, ready, etc.)Context is saved when not runningHas an execution stack and some per-thread static storage for local variablesHas access to the memory address space and resources of its processAll threads of a process share thisWhen one thread alters a (non-private) memory item, all other threads (of the process) sees thatA file opened by one thread, is available to others8Single Threaded and Multithreaded Single Threaded and Multithreaded Process ModelsProcess ModelsThread Control Block contains a register image, thread priority and thread state information9Benefits of Threads vs ProcessesBenefits of Threads vs ProcessesTakes less time to create a new thread than a processLess time to terminate a thread than a processLess time to switch between two threads within the same process10Benefits of ThreadsBenefits of ThreadsClient/Server paradigm Server may need to handle several file requests over a short period of timeMore efficient to create (and destroy) a thread for each requestMultiple threads can execute simultaneously on different processors11Application benefits of threadsApplication benefits of threadsConsider an application that consists of several independent parts that do not need to run in sequenceEach part can be implemented as a threadWhenever one thread is blocked waiting for an I/O, execution could possibly switch to another thread of the same application (instead of switching to another process)12Benefits of ThreadsBenefits of ThreadsSince threads within the same process share memory and files, they can communicate with each other without invoking the kernel Therefore, it becomes necessary to synchronize the activities of various threads so that they do not obtain inconsistent views of the data13Threads StatesThreads StatesThree key states: running, ready, blockedThey have no suspend state because all threads within the same process share the same address spaceIndeed: suspending (ie: swapping) a single thread involves suspending all threads of the same processTermination of a process, terminates all threads within the process14User-Level Threads (ULT)User-Level Threads (ULT)The kernel is not aware of the existence of threadsAll thread management is done by the application, using a thread libraryThread switching does not require kernel mode privileges Scheduling is application specific15Threads libraryThreads libraryContains code for:Creating and destroying threadsPassing messages and data between threadsScheduling thread executionsSaving and restoring thread contexts16Kernel Activity for ULTsKernel Activity for ULTsThe kernel is not aware of thread activity but it is still managing process activityWhen a thread makes a system call, the whole process will be blocked For the thread library that thread is still in the running stateSo thread states are independent of process states17Advantages and inconveniences of ULTAdvantages and inconveniences of ULTAdvantagesThread switching does not involve the kernel: no mode switchingScheduling can


View Full Document

CORNELL CS 414 - UNIX Process Creation

Documents in this Course
Security

Security

49 pages

Processes

Processes

24 pages

Deadlocks

Deadlocks

57 pages

Threads

Threads

5 pages

Threads

Threads

29 pages

Deadlocks

Deadlocks

36 pages

Load more
Download UNIX Process Creation
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 Creation 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 Creation 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?