220 likes | 294 Views
Chapter 6 - Implementing Processes, Threads and Resources. Kris Hansen Shelby Davis Jeffery Brass 3/7/05 & 3/9/05. What’s Covered. Different Process and Thread Types Hardware Processes The Abstract Machine Interface Process Abstraction Thread Abstraction State Diagrams
E N D
Chapter 6 - Implementing Processes, Threads and Resources • Kris Hansen • Shelby Davis • Jeffery Brass • 3/7/05 & 3/9/05
What’s Covered • Different Process and Thread Types • Hardware Processes • The Abstract Machine Interface • Process Abstraction • Thread Abstraction • State Diagrams • Resource Managers
What’s Covered • Different Process and Thread Types • Hardware Processes • The Abstract Machine Interface
Processes • Two Definitions of Process • Classic Process: a program in execution in a von Neumann computer • Modern Process: an OS abstraction that defines the execution environment for a thread or set of threads
Thread • Definition: unit of computation with the minimal internal state and resources • Threads keep track of code execution in a given process • Modern operating systems are built with modern processes and threads in mind
The Abstract Machine • The modern OS uses multiprogramming, the illusion that applications each reside inside of there own computer • The OS manages the virtual machines, via services • Services are invoked by calling API Functions
APIs • API stands for Application Programming Interface • API functions are implemented by different parts of the OS: • Device Manager • Process Manager • Memory Manager • File Manager
Adding Threads • In a classic system, only one thread can be running per processor, the base thread • In a modern OS, additional threads can share the host process’ resources • When an abstract machine is given it’s own multiprogrammed OS, then it is a user space thread implementation • the OS implements classic processes, and the user space thread library runs on top to simulate multiprocessing
Adding Threads • Other modern OSs are built for threads, i.e. Windows, and support kernel threads • When kernel threads are supported, the notions of threads and processes are completely separate by managing both as separate entities
Resources • A resource is anything that a process can request • If not available, the process is blocked • A request for a resource is made via an API call • Allocation results in the resource being configured for the abstract machine • Each resource has a unique system-wide resource identifier
Process Address Space • The process address space is the collection of addresses that a thread can reference • Addresses link to memory locations or other abstract machine elements • Memory-mapped resources - those resources bound to a collection of addresses in the address space • The address space provides a uniform access method for getting memory-mapped resources
Processes Address Space • Each resource manager must bind (associate, or link) addresses to resources • The OS uses the address space system to control what processes have access to resources • Modern OSs usually have 232 address (about 4GB worth,) with some supporting (or planning to support) 264 addresses
OS Families • The abstract interface is determined by the host’s hardware and set of functions released by the OS • The definition of an OS is important, both for how it works on the technical side and what software is available on the business side
Process Manager Responsibilities • Process Creation and Termination • Thread Creation and Termination • Process/Thread Synchronization • Resource Allocation • Resource Protection • Cooperation w/ Device Manager on IO • Address Space Implementation
Final Process Composition • Address Space • Program • Data • Resources • Process Identifier
Final Thread Composition • Host Process Environment • Thread Specific Data • Thread Identifier
The Hardware Process • When a system boots up, there are no distinctions like processes and threads • On booting, all the computer knows is its basic hardware start up instructions, known as a bootstrap • This single thread of execution is known as the hardware process
Bootstrap & Loader • The bootstrap must execute first • Executing the bootstrap leads to the loader, which starts loading the OS • After loading, the OS can initialize, polling and initializing hardware and data structures • Only after this can threads and processes be handled, by way of launching thread and process managers
Initial Structures • When the OS loads, before normal execution can take place, an initial process and thread are created • It acts as a placeholder for all of the other threads and processes, it actually does nothing • This is also the idle thread (or idle process,) as this process is executed when no other processes are running
The Abstract Machine Interface • In an OS, there are two types of instructions: user mode instructions and OS (supervisor mode) instructions • This protects from a program being able to access resources completely unchecked • When a certain resource is needed, or a system call is necessary, then a call must be made to the OS, which directs the call into the supervisor mode via a trap instruction
Comparing System Call Interfaces • Linux Kernel version 2.0.36 has 166 system functions • Kernel version 2.4 has over 200 • Win32 has over 2,000 • The number of system calls increases the functionality of the OS, along with the overhead needed to run it
Source • Nutt, Gary. Operating Systems. Boston: Pearson Education, 2004.