Operating System Operating System Principles Principles Ku-Yaw Chang Ku-Yaw Chang [email protected][email protected]Assistant Professor, Department of Assistant Professor, Department of Computer Science and Information Engineering Computer Science and Information Engineering Da-Yeh University Da-Yeh University
28
Embed
Operating System Principles Ku-Yaw Chang [email protected] Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Operating System Operating System Principles Principles
Assistant Professor, Department of Assistant Professor, Department of Computer Science and Information EngineeringComputer Science and Information Engineering
A threadA thread A basic unit of CPU utilizationA basic unit of CPU utilization
A thread IDA thread ID
A program counterA program counter
A register setA register set
A stackA stack Called Called a lightweight process (LWP)a lightweight process (LWP)
A traditional process has a single thread of control, A traditional process has a single thread of control, called called a heavyweight process (HWP)a heavyweight process (HWP)
A web browserA web browser One thread display images or textOne thread display images or text Another thread retrieves data from the networkAnother thread retrieves data from the network
A word processorA word processor One thread for displaying graphicsOne thread for displaying graphics Another thread for reading keystrokesAnother thread for reading keystrokes Third thread for performing spelling and grammar Third thread for performing spelling and grammar
If new process will perform the same tasks as If new process will perform the same tasks as the existing process, why incur all that the existing process, why incur all that overhead?overhead? Process creation is very time-consuming and Process creation is very time-consuming and
resource intensive.resource intensive. Have the server run as a single process that accepts Have the server run as a single process that accepts
Many systems provide support for both user and Many systems provide support for both user and kernel threadskernel threads Different multithreading modelsDifferent multithreading models
DisadvantageDisadvantage Entire process may block if a thread makes a blocking system Entire process may block if a thread makes a blocking system
callcall Unable to run in parallel on multiprocessorsUnable to run in parallel on multiprocessors
Used on systems that do not support kernel threadsUsed on systems that do not support kernel threads Green threads – a thread library available for SolarisGreen threads – a thread library available for Solaris GNU Portable ThreadsGNU Portable Threads
Multiplex many user-level threads to a small or equal Multiplex many user-level threads to a small or equal number of kernel threads – number of kernel threads – two-level modeltwo-level model
AdvantageAdvantage Developers can create as many as user threads as wishDevelopers can create as many as user threads as wish More concurrencyMore concurrency
ExampleExample IRIXIRIX HP-UXHP-UX Tru64 UnixTru64 Unix Solaris prior to version 9Solaris prior to version 9
A thread libraryA thread library Provide the programmer an API for creating Provide the programmer an API for creating
and managing threadsand managing threads
Two primary approachesTwo primary approaches A user-level libraryA user-level library
Entirely in user space, with no kernel supportEntirely in user space, with no kernel supportA local function call in user spaceA local function call in user space
A kernel-level libraryA kernel-level librarySupported by the operating systemSupported by the operating systemA system call to the kernelA system call to the kernel