Académique Documents
Professionnel Documents
Culture Documents
System Software
• Independent of individual applications,
but common to all of them
• Examples
– C library functions
– A window system
– A database management system
– Resource management functions
– The OS
Operating system Strategies
• Batch systems handle collections or batches of jobs. It does
not allow user to interact with programs while they operate.
• Timesharing system supports multiple interactive users.
Rather than preparing a job for execution ahead of time,
users establish an interactive session with the computer and
then provide commands, programs and data as they are
needed during the session.
• Personal computers and workstations established a trend
away from sharing a single computer among multiple users
and towards an environment in which the entire machine is
devoted to a single human user.
• Dedicated system supports real-time and process control
system. The dedicated strategy must guarantee certain
response times for particular computing tasks or the
application is useless.
- Advanced Operating system
Handouts for Lecture 4 to 6
Operating System Organization
Resource Management
• Under Abstraction
o Functional complexity
o A single abstraction over multiple
devices
o Replication → reliability
• Objective of Resource sharing
o Efficiency
o Fairness
o Security / protection
Kernel
The part of the OS critical to correct operation (trusted software)
• Executes in supervisor mode
• The trap instruction is used to switch from user to supervisor mode, entering the OS
Monolithic Kernel
Micro Kernel Architecture
Architecture
Bootstrap loader
I/O Devices
• Each I/O device consists of a device controller and the
physical device itself.
• Device controller: hardware that connects the device to
the computer.
– continuously monitors and controls the
operation of the device.
– provides an interface to the computer.
• The device communicates with the computer via a
communication point called a port.
How does the CPU know when a device controller has completed the requested operation?
• 1. Polling: CPU continually check status register of device controller
• 2. Interrupt driven I/O: device controller sends a signal to CPU through the bus.
– bus must support interrupts
– CPU must include an interrupt flag
– CPU instruction set must include instructions to test and set/clear interrupt flag.
- Advanced Operating system
Handouts for Lecture 9 to 10
Device Management
Design Goal
Efficiency
• Most I/O devices are extremely slow compared with the processor and the main memory
– Buffering is one way to deal with this issue
Generality
• It is desirable to handle all devices in a uniform and consistent manner
• Applies for both
– The way the user processes see the devices
– The way the operating system manages the I/O devices and operations
Buffering
• Buffering is the technique by which the device manager can keep slower I/O devices busy during times
when a process is not requiring I/O operations.
• Input buffering is the technique of having the input device read information into the primary memory
before the process requests it.
• Output buffering is the technique of saving information in memory and then writing it to the device while
the process continues execution
Process Process Process
Hardware Buffering
• Add a hardware buffer to the controller to decrease the Controller Controller Controller
amount of time the process has to wait A B A B
Data Register Data Registers Data Registers
• The other buffer is to store data from the lower level module Controller Controller
A B
• This technique can be used for the block-oriented devices (buffers must be A
Data Registers
B
Data Registers
There are several different devices in Linux. User space and kernel space
When you write device drivers, it’s important to make the distinction between “user space” and “kernel space”.
• Kernel space. Linux (which is a kernel) manages the machine's hardware in a simple and efficient manner, offering the
user a simple and uniform programming interface. In the same way, the kernel, and in particular its device drivers, form
a bridge or interface between the end-onuser/programmer and the hardware. Any subroutines or functions forming part
of the kernel (modules and device drivers, for example) are considered to be part of kernel space.
• User space. End-user programs, like the UNIX shell or other GUI based applications (kpresenter for example), are
part of the user space. Obviously, these applications need to interact with the system's hardware . However, they don’t
do so directly, but through the kernel supported functions.
On the other hand, in kernel space Linux also offers several functions or subroutines to perform the low level
interactions directly with the hardware, and allow the transfer of information from kernel to user space.
Usually, for each function in user space (allowing the use of devices or files), there exists an equivalent in kernel
space (allowing the transfer of information from the kernel to the user and vice-versa).
Table 1. Device driver events and their associated interfacing functions in kernel space and user space.
Events User functions Kernel functions
Load module insmod module_init( ) (default)
Open device open, fopen file_operation :open
Read device read, fread file_operation :read
Write device write, fwrite file_operation :write
Close device close, fclose file_operation :release
Remove module rmmod module_exit( ) (default)
Table 2. Device driver events and their associated functions between kernel space and the hardware device.
Events Kernel functions
Read data
Write data
- Advanced Operating system
Handouts for Lecture 13, 14
Process and Thread
Classic process
• OS implements {abstract machine} – one per task
• Multiprogramming enables N programs to be space-
muxed in executable memory, and time-muxed across
the physical machine processor.
• Result: Have an environment in which there can be
multiple programs in execution concurrently*, each as a
processes
Modern process
• Divide classic process:
– Process is an infrastructure in which execution
takes place – address space + resources
– Thread is a program in execution within a
process context – each thread has its own stack
Address Space
• Process must be able to reference every resource in its abstract machine
• Assign each unit of resource an address
– Most addresses are for memory locations
– Abstract device registers
– Mechanisms to manipulate resources
• Addresses used by one process are inaccessible to other processes
• Say that each process has its own address space
• Classic processes sharing program ⇒ shared address space support
• Thread model simplifies the problem
– All threads in a process implicitly use that process’s address space , but no “unrelated threads”
have access to the address space
– Now trivial for threads to share a program and data
• If you want sharing, encode your work as threads in a process
• If you do not want sharing, place threads in separate processes
• User threads
o Thread data structure is in user-mode memory
o scheduling done at user mode
• Kernel threads
o Thread data structure is in kernel memory
o scheduling done by the OS kernel
• What is really happening when the execution of one thread switches to another?
o save the registers (including the SP) of the old thread; while in process save entire context (user
context, register context, and system context)
o restore the registers of the new thread;
o set the new PC appropriately for the new thread;
Distributed File System (DFS) allows administrators to group shared folders located on different servers and present
them to users as a virtual tree of folders known as a namespace. A namespace provides numerous benefits, including
increased availability of data, load sharing, and simplified data migration.
Remote file systems were the first heavily used mechanism to take advantage of high speed networking.
The concepts of various strategies of remote files help us to design an OS to distribute a file system across machines
on a network. There are three general strategies :
Remote Disk : In this strategy, the file manager interacts with storage devices located on remote machines.
Remote file system : The file manager functionality is distributed between local and remote machines.
File-caching : Os automatically copy files from remote machines, keep multiple copies consistent, and
restore the copy to its original machine when the file is closed.
Distributed Computing