Download presentation
Presentation is loading. Please wait.
Published byShona Pierce Modified over 9 years ago
1
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6
2
Slide 6-2 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Implementing Processes, Threads, and Resources 6
3
Slide 6-3 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Processes Process Concept Process Scheduling Operating on Processes Threads Internet Links to Multi-threads: –IBMIBM –Tom Wagner SiteTom Wagner Site
4
Slide 6-4 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Concept An operating system executes a variety of programs: –Batch systems -- Jobs –Time-Shared system -- user programs or tasks A Process -- a program in execution A Process -- a schedulable unit of computation There may be several processes executing the same program at the same time. E.g. several users running vi at the same time: –Each instance of vi creates a separate process.
5
Slide 6-5 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 OS Address Space OS Address Space Implementing the Process Abstraction Control Unit OS interface … Machine Executable Memory ALU CPU P i Address Space P i Address Space P i CPU P i Executable Memory P i Executable Memory P k Address Space P k Address Space … P k CPU P k Executable Memory P k Executable Memory P j Address Space P j Address Space P j CPU P j Executable Memory P j Executable Memory
6
Slide 6-6 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 External View of the Process Manager Hardware Application Program Application Program Device MgrProcess MgrMemory Mgr File Mgr UNIX Device MgrProcess MgrMemory Mgr File Mgr Windows CreateThread() CreateProcess() CloseHandle() WaitForSingleObject() fork() exec() wait()
7
Slide 6-7 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Manager In a multi-programmed OS, several processes can be “executed at the same time”. The Process Manager is that part of the OS that is responsible for managing all the processes on the system. When the computer is powered on, there is only one program in execution: the initial process. The initial process creates the OS, which can then create other processes as needed. A process can create another process with a system call (e.g. fork in UNIX). The created process is called a child process
8
Slide 6-8 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Manager When a process is created, it specifies to the Process Manager its resource needs (e.g. memory requirements, files etc.) The Process Manager allocates the needed resources and causes the process to be executed. The process manager is responsible –for monitoring the state of each process executing on the system –process scheduling on CPU –process synchronization and deadlock –protection & security
9
Slide 6-9 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Manager Responsibilities Define & implement the essential characteristics of a process and thread –Algorithms to define the behavior –Data structures to preserve the state of the execution Define what “things” threads in the process can reference – the address space (most of the “things” are memory locations) Manage the resources used by the processes/threads Tools to create/destroy/manipulate processes & threads Tools to time-multiplex the CPU – Scheduling the (Chapter 7) Tools to allow threads to synchronization the operation with one another (Chapters 8-9) Mechanisms to handle deadlock (Chapter 10) Mechanisms to handle protection (Chapter 14)
10
Slide 6-10 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6
11
Slide 6-11 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Model A process is composed of the following elements: –a program (code) –The data operated on by the process –A set of resources to provide an environment for execution –A Process Descriptor: a record kept by the OS to keep track of the progress of each process.Process Descriptor
12
Slide 6-12 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Modern Processes and Threads OS interface … … … P i CPU Thrd j in P i Thrd k in P i …
13
Slide 6-13 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Processes &Threads Address Space Map Stack State Program Static data Resources Stack State Map
14
Slide 6-14 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Address Space A process address space includes: –program code –data section –stack section Process Descriptor is kept in OS space. Program text Data Section Main Memory Stack Section
15
Slide 6-15 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 The Address Space Process Address Space Address Binding Executable Memory Other objects Files
16
Slide 6-16 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Building the Address Space Some parts are built into the environment –Files –System services Some parts are imported at runtime –Mailboxes –Network connections Memory addresses are created at compile (and run) time
17
Slide 6-17 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Tracing the Hardware Process Bootstap Loader Process Manager Interrupt Handler P1P1 P,2 PnPn … Machine is Powered up Initialization Load the kernel Service an interrupt Hardware process progress Execute a thread Schedule
18
Slide 6-18 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 The Abstract Machine Interface User Mode Instructions User Mode Instructions Application Program User Mode Instructions Abstract Machine Instructions Trap Instruction Supervisor Mode Instructions Supervisor Mode Instructions fork() create() open() OS
19
Slide 6-19 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Context Switch
20
Slide 6-20 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Context Switching Process Manager Interrupt Handler P1P1 P2P2 PnPn Executable Memory Initialization 1 2 3 4 5 7 Interrupt 8 9 6
21
Slide 6-21 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Descriptors OS creates/manages process abstraction Descriptor is data structure for each process –Register values –Logical state –Type & location of resources it holds –List of resources it needs –Security keys –etc. (see Table 6.3 and the source code of your favorite OS)
22
Slide 6-22 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Descriptor Contains information associated with a process: PID Process state Owner Parent process List of child processes list of allocated resources list of open files …. Copy of CPU registers at the last time the process executed on the CPU Process Descriptor Table
23
Slide 6-23 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 EPROCESS … void *UniqueProcessId; … NT Executive Windows NT Process Descriptor KPROCESS … uint32 KernelTime; uint32 UserTime; … Byte state; NT Kernel
24
Slide 6-24 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Windows NT Process Descriptor (2) Kernel process object including: Pointer to the page directory Kernel & user time Process base priority Process state List of the Kernel thread descriptors that are using this process
25
Slide 6-25 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Windows NT Process Descriptor (3) Parent identification Exit status Creation and termination times. Memory status Security information executable image Process priority class used by the thread scheduler. A list of handles used by this process A pointer to Win32-specific information
26
Slide 6-26 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 ETHREAD Windows NT Thread Descriptor EPROCESS KPROCESS NT Kernel KTHREAD NT Executive
27
Slide 6-27 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Creating a Process in UNIX pid = fork(); UNIX kernel … Process Table Process Descriptor
28
Slide 6-28 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Model CONTD Process creation/initialization: –Process Descriptor is created and initialized –Resources needed by the process are allocated (e.g. files, memory to store code, data, and stack). –Process may inherent some resources from its parent (e.g. open files, etc.) –Process Descriptor must reflect all allocated resources –Process is loaded in memory, into its Address Space, ready to begin executionAddress Space –From then on, process competes for CPU and other resources with other processes.
29
Slide 6-29 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Creation
30
Slide 6-30 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Creation
31
Slide 6-31 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Termination Process executes last statement and asks the operating system to delete it –process resources are de-allocated by the operating system A process may be terminated by another process –A parent terminates the execution of its children When a process exits what happens to its children? –do not allow a child to exist if its parent has terminated ==> cascaded termination (VMS) –allow children to exist after parent ==> orphan processes (UNIX )
32
Slide 6-32 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Creating a Process in NT CreateProcess(…); Win32 Subsystem ntCreateProcess(…); … ntCreateThread(…); NT Executive NT Kernel … Handle Table Process Descriptor
33
Slide 6-33 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Windows NT Handles
34
Slide 6-34 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Simple State Diagram Ready Blocked Running Start Schedule Request Done Request Allocate
35
Slide 6-35 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Model CONTD
36
Slide 6-36 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Scheduling Queues
37
Slide 6-37 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 UNIX State Transition Diagram Runnable Uninterruptible Sleep Running Start Schedule Request Done I/O Request Allocate zombie Wait by parent Sleeping Traced or Stopped Request I/O Complete Resume
38
Slide 6-38 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Windows NT Thread States Initialized CreateThread Ready Activate Select Standby Running Terminated Waiting Transition Reinitialize Exit Preempt Dispatch Wait Wait Complete Dispatch
39
Slide 6-39 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Model CONTD Each process uses resources as it executes; main memory, I/O devices, files, and the CPU The CPU is also a hardware resource During execution a process may request other resources (e.g. more memory) and may release some of its resources ==> dynamic allocation/de-allocation When a process can NOT get its requested resources it gets blocked in a queue waiting for that resource. Multiprogramming: While one process uses the CPU, the remaining are using I/O resources or waiting for a resource (I/O or CPU) to be available.
40
Slide 6-40 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Resources R = {R j | 0 j < m} = resource types C = {c j 0 | R j R (0 j < m)} = units of R j available Reusable resource: After a unit of the resource has been allocated, it must ultimately be released back to the system. E.g., CPU, primary memory, disk space, … The maximum value for c j is the number of units of that resource Consumable resource: There is no need to release a resource after it has been acquired. E.g., a message, input data, … Notice that c j is unbounded. Resource: Anything that a process can request, then be blocked because that thing is not available.
41
Slide 6-41 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Using the Model There is a resource manager, Mgr(R j ) for every R j Mgr(R j ) Process p i can only request n i c j units of reusable R j p i can request unbounded # of units of consumable R j Process p i can request units of R j if it is currently running request Mgr(R j ) can allocate units of R j to p i allocate
42
Slide 6-42 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 A Generic Resource Manager Process Resource Manager Process Blocked Processes Resource Pool request() release() Policy
43
Slide 6-43 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Hierarchies Parent-child relationship may be significant: parent controls children’s execution Ready-Active Blocked-Active Running Start Schedule Request Done Request Allocate Ready-Suspended Blocked-Suspended Suspend Yield Allocate Suspend Activate
44
Slide 6-44 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Manager Overview Program Process Abstract Computing Environment File Manager Memory Manager Device Manager Protection Deadlock Synchronization Process Description Process Description CPU Other H/W Scheduler Resource Manager Resource Manager Resource Manager Resource Manager Resource Manager Resource Manager Memory Devices
45
Slide 6-45 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 UNIX Organization System Call Interface File Manager Memory Manager Device Manager Protection Deadlock Synchronization Process Description Process Description CPU Other H/W Scheduler Resource Manager Resource Manager Resource Manager Resource Manager Resource Manager Resource Manager Memory Devices Libraries Process Monolithic Kernel
46
Slide 6-46 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Windows NT Organization Processor(s)Main MemoryDevices Libraries Process Subsystem User Subsystem Hardware Abstraction Layer NT Kernel NT Executive I/O Subsystem T T T T T T TT T
47
Slide 6-47 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 UNIX Processes Each process has its own address space –subdivided into code, data & stack –a.out file describes the address apace OS creates a Process Descriptor to manage each process. The collection of all Process Descriptors is referred to as the Process Descriptor Table
48
Slide 6-48 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 UNIX Processes Each process is assigned a unique process ID (PID) The PID is essentially a pointer into the Process Table of the OS. A process can use the system call getpid() to obtain its own PID Each process has one parent process (the process that created it), except for process 1 Process 1 ( the init process) is the ancestor of all other processes a process can use the system call getppid() to obtain the PID of it parent (i.e. PPID)
49
Slide 6-49 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 UNIX Processes When Unix is first started, it has only one process. The process is called "init", and its PID is 1. The "init" process creates other operating system processes to do OS functions For each port supporting user logins (e.g. a terminal), init creates a process running the getty program. The getty process waits for a user to begin using the port. When the port begins to be used, getty creates a new process to run the login program.
50
Slide 6-50 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 UNIX Processes The login process prompts the user for username and password, reads the username and password and verifies by looking up the /etc/passwd file. If login successful, the login process changes directory to the user's directory and creates a new process running the shell program specified in the user's entry of the /etc/passwd file. The shell process displays a "shell prompt" on the terminal and waits for the user to type a command.
51
Slide 6-51 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 UNIX Processes When the user types a command, the shell process, reads it, parses it, verifies it, and creates a new process running the program specified in the command. In the mean time, the shell process gets suspended until the command process finishes. When the command process is done, the shell process is resumed again. When the user logs out, the shell process is terminated and the login process is resumed, etc. etc. etc.
52
Slide 6-52 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 UNIX Processes UNIX fork creates a process UNIX wait allows a process to wait for a child to terminate UNIX exec allows a child to run a new program
53
Slide 6-53 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Creating Processes UNIX fork() creates a process fork( ) creates a child process that is identical to its parent, except that it has: –a different and unique PID –a different PPID fork() –creates a new address space for the child process –copies code, data and stack into new address space –provides child with access to open files of parent.
54
Slide 6-54 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Creation: fork int pid; pid = fork(); the fork is called by the parent but returns in both the parent and the child –In the parent, it returns the PID of the child process –in the child it returns 0 If fork() fails no child is created and -1 is returned to the parent. After the child is created, the parent and the child processes execute concurrently starting from the instruction following the fork. Since only one can be using CPU at a time, either may go first.
55
Slide 6-55 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Process Creation: fork int pid; pid = fork( ); if ( pid == 0 ) { /* code for child here */ exit(0); } if (pid < 0) { /* fork failed... Put error handling code here */ } /*remaining code for parent goes here */
56
Slide 6-56 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 #include int main( ) {int pid; if ( (pid = fork( ) ) == 0 ) {printf(“I am the child, my pid=%d and my parent pid=%d\n”, getpid( ), getppid( ) ); exit(0); } if (pid < 0) {fprintf(stderr, “fork failed\n”) exit(1); } printf(“I am the parent, my pid=%d\n”, getpid( ) ); }
57
Slide 6-57 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Example: Chain of Processes #include int i, n, pid; for (i=1, i < n; ++i ) if ( ( pid=fork() ) != 0) break; fprintf(stdout,”This is process %d with parent %d\n”, getpid(),getppid() );
58
Slide 6-58 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Example: a fan of processes #include int i, n, pid; for (i=1, i<n; ++i) if ( (pid=fork()) == 0) break; fprintf(stdout,”This is process %d with parent %d\n”, getpid(),getppid() );
59
Slide 6-59 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Synchronization of Parent and Child What happens to the parent after it creates a child? –They both execute concurrently If parent wants to wait until the child terminates before proceeding further it executes a wait() or waitpid() system call. When a process is terminated (with exit( ) ), a signal is sent to its parent notifying it of the termination.
60
Slide 6-60 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 exit( ) void exit(int status) exit( ) closes all process' file descriptors, de- allocates code, data, and stack, and then terminates the process. It sends a signal to the parent process telling of its termination status and waits until the parent accepts the signal. A process that is waiting for its parent to accept its termination is called a "zombie" A parent accepts a child's termination by executing wait( ).
61
Slide 6-61 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Synch. of Parent and Child int pid; pid = fork( ); if ( pid == 0 ) { /* child executes this part concurrently with parent */ exit(0); } /*parent works concurrently with child and independent of each other*/
62
Slide 6-62 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Synch. of Parent and Child int pid; pid = fork( ); if ( pid == 0 ) { /* child executes this part concurrently with parent */ exit(0); } wait(...); /* parent waits for child*/ /*parent proceeds*/
63
Slide 6-63 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Synch. of Parent and Child If a parent terminates without waiting for a child, child becomes an orphan and is adopted by the system init process by setting their PPID to 1. init periodically executes wait( ) to remove zombies from the system.
64
Slide 6-64 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Wait() #include int wait(int *status); 1. if there are no child processes, wait returns with -1 (an error) 2. if one or more processes are already in the zombie state, wait selects an arbitrary one, stores its status in status, and returns its PID 3. otherwise, wait sleeps until one of the child processes terminates and then goes to step 2
65
Slide 6-65 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Child Executing a Different Program Parent process calls fork to create a child process child process calls an exec system call. The exec system call replaces the address space of the child with a new program several exec calls: execv, execvp, etc. int execv(char *filename, char *argv[ ]); filename is the name of an executable file argv is the command-line arguments for the executable program.
66
Slide 6-66 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Example:Parent main( ) { int pid; /*code to set up the argv array for the child here*/ pid = fork(); if (pid==0) { execv(child_prog, argv); /* execv does not return unless there is an error*/ fprintf(stderr,”error in the exec…terminating child..”); exit(1); } wait( );/*parent waits for child to terminate*/ …….}
67
Slide 6-67 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Example:Child File child_prog.c: main( ) { /* code to be executed by child process */ } child_prog.c must be compiled into an executable file.
68
Slide 6-68 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Threads (read Chap2) A thread (or lightweight process) is a basic unit of computation. It uses less state and less resources than heavyweight process In a system that supports threads, each (heavyweight) process consist of one or more threads. A traditional process is a process with one thread.
69
Slide 6-69 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Threads
70
Slide 6-70 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Threads Each thread has its own –thread ID –program counter –stack space –possibly some of its own data A thread shares with its sibling threads: –code section –data section –operating system resources (e.g. open files, CPU)
71
Slide 6-71 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 POSIX Threads DEC Unix conforms to the POSIX standard ==> # include When a thread is created it is assigned a thread ID, a stack, a starting address for execution. pthread_create(ChildID, Thread_attributes, function_name, arguments) –ChildID is the returned child ID –Thread_attributes: set to NULL for default attributes –function_name: function to be executed by the thread –arguments: a pointer to the argument to be passed to the function
72
Slide 6-72 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Why threads? Reduced context switching overhead An application that needs to block occasionally waiting for I/O (e.g. disk): While one thread waits, a second thread can run and do other computation==> better performance for the application. Windowing systems: –heavyweight process: physical screen manager –a thread for each window: all threads share the same physical screen.
73
Slide 6-73 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Threads for a windows system
74
Slide 6-74 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 Why threads? Since sibling threads use same data segment, data sharing among cooperating threads is easily achieved + Applications that require sharing a common buffer (e.g. producer-consumer) can benefit from thread utilization. –no protection between threads: synchronization among threads when accessing shared data must be enforced by the programmer. Threads can be used in multiprocessor systems (each thread runs on a separate processor, they all share same address space on a shared memory).
75
Slide 6-75 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 User vs. kernel threads A heavyweight process consists of one or more sibling threads, all competing for the processor A thread scheduler (or thread manager) switches the processor among the threads. In some systems, the thread manager is a user program, supported by a thread library (user- supported threads)-- older versions of UNIX In other systems the thread manager is part of the OS (kernel-supported threads)-- OS/2, NT, Solaris
76
Slide 6-76 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6 User vs. kernel threads User threads: –switching among threads is faster -- since they don’t involve calling the kernel –Any call to the OS can cause the whole heavywheight process to be context switched out of the CPU (since in this case OS supports only process scheduling). – Thread scheduling can be unfair, in favor of processes with large number of threads
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.