DOC PREVIEW
UCSC CMPS 111 - Processes and Threads

This preview shows page 1-2-3-4-25-26-27-52-53-54-55 out of 55 pages.

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

Unformatted text preview:

Processes and ThreadsProcesses The Process ModelProcess CreationProcess TerminationProcess HierarchiesProcess States (1)Process States (2)Implementation of Processes (1)Implementation of Processes (2)Threads The Thread Model (1)The Thread Model (2)The Thread Model (3)Thread Usage (1)Thread Usage (2)Thread Usage (3)Thread Usage (4)Implementing Threads in User SpaceImplementing Threads in the KernelHybrid ImplementationsScheduler ActivationsPop-Up ThreadsMaking Single-Threaded Code Multithreaded (1)Making Single-Threaded Code Multithreaded (2)Interprocess Communication Race ConditionsCritical Regions (1)Critical Regions (2)Mutual Exclusion with Busy Waiting (1)Mutual Exclusion with Busy Waiting (2)Mutual Exclusion with Busy Waiting (3)Sleep and WakeupSemaphoresMutexesMonitors (1)Monitors (2)Monitors (3)Monitors (4)Message PassingBarriersDining Philosophers (1)Dining Philosophers (2)Dining Philosophers (3)Dining Philosophers (4)The Readers and Writers ProblemThe Sleeping Barber Problem (1)The Sleeping Barber Problem (2)Scheduling Introduction to Scheduling (1)Introduction to Scheduling (2)Scheduling in Batch Systems (1)Scheduling in Batch Systems (2)Scheduling in Interactive Systems (1)Scheduling in Interactive Systems (2)Scheduling in Real-Time SystemsPolicy versus MechanismThread Scheduling (1)Thread Scheduling (2)1Processes and ThreadsChapter 22.1 Processes2.2 Threads2.3 Interprocess communication2.4 Classical IPC problems2.5 Scheduling2ProcessesThe Process Model•Multiprogramming of four programs•Conceptual model of 4 independent, sequential processes•Only one program active at any instant3Process CreationPrincipal events that cause process creation1. System initialization2. Execution of a process creation system 3. User request to create a new process4. Initiation of a batch job4Process TerminationConditions which terminate processes1. Normal exit (voluntary)2. Error exit (voluntary)3. Fatal error (involuntary)4. Killed by another process (involuntary)5Process Hierarchies•Parent creates a child process, child processes can create its own process•Forms a hierarchy–UNIX calls this a "process group"•Windows has no concept of process hierarchy–all processes are created equal6Process States (1)•Possible process states–running–blocked–ready•Transitions between states shown7Process States (2)•Lowest layer of process-structured OS–handles interrupts, scheduling•Above that layer are sequential processes8Implementation of Processes (1)Fields of a process table entry9Implementation of Processes (2)Skeleton of what lowest level of OS does when an interrupt occurs10ThreadsThe Thread Model (1)(a) Three processes each with one thread(b) One process with three threads11The Thread Model (2)•Items shared by all threads in a process•Items private to each thread12The Thread Model (3)Each thread has its own stack13Thread Usage (1)A word processor with three threads14Thread Usage (2)A multithreaded Web server15Thread Usage (3)•Rough outline of code for previous slide(a) Dispatcher thread(b) Worker thread16Thread Usage (4)Three ways to construct a server17Implementing Threads in User SpaceA user-level threads package18Implementing Threads in the KernelA threads package managed by the kernel19Hybrid Implementations Multiplexing user-level threads onto kernel- level threads20Scheduler Activations•Goal – mimic functionality of kernel threads–gain performance of user space threads•Avoids unnecessary user/kernel transitions•Kernel assigns virtual processors to each process–lets runtime system allocate threads to processors•Problem: Fundamental reliance on kernel (lower layer) calling procedures in user space (higher layer)21Pop-Up Threads•Creation of a new thread when message arrives(a) before message arrives(b) after message arrives22Making Single-Threaded Code Multithreaded (1)Conflicts between threads over the use of a global variable23Making Single-Threaded Code Multithreaded (2)Threads can have private global variables24Interprocess CommunicationRace ConditionsTwo processes want to access shared memory at same time25Critical Regions (1)Four conditions to provide mutual exclusion1. No two processes simultaneously in critical region2. No assumptions made about speeds or numbers of CPUs3. No process running outside its critical region may block another process4. No process must wait forever to enter its critical region26Critical Regions (2)Mutual exclusion using critical regions27Mutual Exclusion with Busy Waiting (1)Proposed solution to critical region problem(a) Process 0. (b) Process 1.28Mutual Exclusion with Busy Waiting (2)Peterson's solution for achieving mutual exclusion29Mutual Exclusion with Busy Waiting (3)Entering and leaving a critical region using the TSL instruction30Sleep and WakeupProducer-consumer problem with fatal race condition31SemaphoresThe producer-consumer problem using semaphores32MutexesImplementation of mutex_lock and mutex _unlock33Monitors (1)Example of a monitor34Monitors (2)•Outline of producer-consumer problem with monitors–only one monitor procedure active at one time–buffer has N slots35Monitors (3)Solution to producer-consumer problem in Java (part 1)36Monitors (4)Solution to producer-consumer problem in Java (part 2)37Message PassingThe producer-consumer problem with N messages38Barriers•Use of a barrier–processes approaching a barrier–all processes but one blocked at barrier–last process arrives, all are let through39Dining Philosophers (1)•Philosophers eat/think•Eating needs 2 forks•Pick one fork at a time •How to prevent deadlock40Dining Philosophers (2)A nonsolution to the dining philosophers problem41Dining Philosophers (3)Solution to dining philosophers problem (part 1)42Dining Philosophers (4)Solution to dining philosophers problem (part 2)43The Readers and Writers ProblemA solution to the readers and writers problem44The Sleeping Barber Problem (1)45The Sleeping Barber Problem (2)Solution to sleeping barber problem.46SchedulingIntroduction to Scheduling (1)•Bursts of CPU usage alternate with periods of I/O wait–a CPU-bound process–an I/O bound process47Introduction to Scheduling (2)Scheduling Algorithm Goals48Scheduling in Batch Systems (1)An example of shortest job first scheduling49Scheduling in Batch Systems (2)Three level scheduling50Scheduling in Interactive Systems (1)•Round Robin Scheduling–list of runnable processes–list of runnable processes after


View Full Document

UCSC CMPS 111 - Processes and Threads

Download Processes and Threads
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 Processes and Threads 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 Processes and Threads 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?