Professional Documents
Culture Documents
• Abstractions
corresponds to applications that OS executes
process, thread, file, socket, memory page
• Mechanisms
on top of Abstractions
create, schedule, open, write, allocate
• Policies
how mechanisms are used to manage underlying hardware
Least Recently Used (LRU)
OS services
• process management
• file management
• device management
• memory management
• storage management
• Security, etc
User-kernel Boundary
• user-mode/unprivileged mode : where applications execute.
• kernel-mode/ privileged mode: OS Kernel executes [here hardware
access is allowed]
• Mode bit provided by hardware
• Mode bit = 0; kernel mode
• Mode bit = 1; user mode
• Mode bit provides ability to distinguish when system is running user
code or kernel code
• Some instructions designated as privileged, only executable in kernel
mode
• System call changes mode to kernel, return from call resets it to user
System Calls
System Calls
• It provides programming interface to the services provided by the OS
• Typically written in a high-level language (C or C++)
• Mostly accessed by programs via a high-level Application Programming
Interface (API) rather than direct system call use
• Three most common APIs are Win32 API for Windows, POSIX API for
POSIX-based systems (including virtually all versions of UNIX, Linux, and
Mac OS X), and Java API for the Java virtual machine (JVM)
Types of System Calls
• Process control - create process, terminate process, load, execute, get
process attributes, set process attributes, wait for time etc.
• File management- create file, delete file, open, close file,read, write, etc.
• Device management-request device, release device etc
Example
• System call sequence to copy the contents of one file to another file
System call Implementation
• is an active entity
• An executing unit of a process
• Process creation is heavy-weight while thread creation is light-weight
• Threads of same process share address space, code, data, files
• Each thread will have separate execution context- registers, stack,
value of program counter.
• PCB for multi-threaded application contains information – shared
among all threads and thread specific information.
• User threads - management done by user-level threads library
• Kernel threads - Supported by the Kernel
Single and Multithreaded Processes
PCB for multi-threaded application
Many-to-One
• Many user-level threads mapped to single
kernel thread
• One thread blocking causes all to block
• Multiple threads may not run in parallel on
muticore system because only one may be in
kernel at a time
• User level thread management library for
scheduling, synchronization, etc
• Few systems currently use this model
• Examples:
• Solaris Green Threads
• GNU Portable Threads
One-to-One
• Each user-level thread maps to kernel thread
• Creating a user-level thread creates a kernel
thread
• More concurrency than many-to-one
• Number of threads per process sometimes
restricted due to overhead
• User level threads directly benefit from thread
support available in kernel.
• Examples
• Windows
• Linux
• Solaris 9 and later
Many-to-Many Model
• Data Race- when multiple threads access shared data and try to
manipulate it at same time. So outcome depends on the order in which
data manipulation took place
• So critical section segment is piece of code where thread or process
may be changing common variables, updating table, writing file, etc
• When one process in critical section, no other may be in its critical
section.
• Each process must ask permission to enter critical section in entry
section, may follow critical section with exit section, then remainder
section
Solution to Critical Section