Presentation is loading. Please wait.

Presentation is loading. Please wait.

ITFN 3601 Introduction to Operating Systems Lecture 3 Processes, Threads & Scheduling Intro.

Similar presentations


Presentation on theme: "ITFN 3601 Introduction to Operating Systems Lecture 3 Processes, Threads & Scheduling Intro."— Presentation transcript:

1 ITFN 3601 Introduction to Operating Systems Lecture 3 Processes, Threads & Scheduling Intro

2 Agenda Processes Creation Termination States Threads Definition User vs. Kernel Threads Hybrid Threads Intro to Scheduling

3 Processes A process is an executing Program Consist of Program, input, output and a state Multiprogramming Pseudo-Parallel Execution

4 Process Creation System Initialization System call by running process User request to create new process Initiation of a batch job

5 Process Termination Normal exit Error Exit Fatal Error Killed by another process

6 Process Internals States Running Ready Blocking Process Control Block State Registers & Memory PC, SP, Files Running Ready Blocked

7 Threads Lightweight Processes Threads handle all execution activities A thread is a program counter, a stack, and a set of registers Thread creation is relatively cheap in terms of CPU costs

8 Thread Usage Programming model becomes simpler Easy to create and destroy Speeds up applications Useful on systems with multiple CPUs

9 User-level threads User-level threads are managed by runtime library routines linked into each application so that thread management operations require no thread intervention User-level threads are also flexible; they can be customized to the needs of the language or user without kernel modification User-level threads execute within the context of traditional processes

10 Advantages and Disadvantages of User-Level Threads Thread operations do not have to cross protection boundary Parameters do not need to be copied Applications can link in the correct thread management policy for their needs

11 Advantages and Disadvantages of User-Level Threads Performance is inherently better in user- level threads User-level threads that issue blocking calls to the kernel will block an entire process

12 Threads in the Kernel Avoids the system integrations problems exhibited by user-level threads because the kernel directly schedules each applications threads onto physical processors Performance has been typical of an order magnitude worse than the best-case performance of user-level threads. Employ user-level threads, which have good performance and correct behavior provided the application is uniprogrammed and does no I/O, or employ kernel threads, which have worse performance but are not as restricted

13 Advantages and Disadvantages of Kernel-Level Threads Kernel threads are expensive! Kernel does not understand application behavior

14 User vs. Kernel Threads Software Threads No System Calls for Swapping Process-Blocking System Calls Dual-Conflicting Swaps Process Level Thread Kernel Level Process OS Threads Kernel Calls to Swap Threads Thread-Blocking System Calls Dual-Coordinated Swaps Kernel Level Thread Kernel Level Process

15 Hybrid Implementation Scheduler Activation Thread-aware Kernel for User-threads Violates Fundamental ‘Flow-of-Control’ Upcalls Pop-Up Threading Implicit Thread Creation Receives Message and processes them

16 Scheduler Activations Threads are needed for parallel applications User-level and kernel-level threads both have problems User-level threads offer good performance, but do not handle I/O well Kernel-level threads are expensive, but correct

17 Scheduler Activations SAs notify user-level schedulers of changes in kernel scheduling decisions SAs provide kernel space for threads that block in the kernel Create one activation for each virtual processor Kernel creates SAs to upcall into applications, notifying them of scheduling events

18 Scheduler Activations Key difference between SAs and kernel threads When an SA blocks, the application is notified by a different SA The blocking SA’s thread is marked blocked and the old SA is freed The new SA can now be scheduled The number of SAs under control of the application never changes (unless requested/told explicitly) Kernel level state is passed to thread system on upcall, so that registers of the blocking thread are accessible to the user-level scheduler

19 Popup Threads Thread is created spontaneously to handle an incoming request Incoming message mapped into thread’s address space Advantages over traditional request: No waiting on work (no context needs to be saved) Creating new thread is cheaper than restoring old thread (no context is saved)

20 Process Control Each Process must maintain it’s own PCB Information that Multiple Processes may use is duplicated

21 Thread Control Each Process has a PCB Each Thread has a TCB Shared information is Shared, not Duplicated

22 Scheduling Process Conditions Processor Bound I/O Bound Scheduling how? Preemptive Non-preemptive

23 Scheduler Goals Generic goals Fairness of processor allocation Enforcement of scheduling policies Balance of utilization Batch-based goals Throughput of jobs Turnaround on jobs

24 Scheduler Goals II Interactive System Goals Response time for user I/O Proportions should be maintained Real-time System Goals Deadlines must be met for process completion System performance must be predictable

25 The End


Download ppt "ITFN 3601 Introduction to Operating Systems Lecture 3 Processes, Threads & Scheduling Intro."

Similar presentations


Ads by Google