Vous êtes sur la page 1sur 13

- Advanced Operating system

Handouts for Lecture 1 to 2


Overview of Operating System
Operating System
• A program or collection of programs that act as intermediary between the user of a computer and the
computer hardware.
• Operating system goals:
– Make the computer convenient to use.
– Use computer resources in an efficient manner.
– Coordinate among the various users and programs that are competing for computing resources.
• Aim to learn Operating system:
– Help to design OS components
– Help to design system software
– Help you to write efficient code by understanding model of operations
Application software, System Software and Operating system

• OS provides an interface between the computer


hardware and users, applications and system software.
• OS is domain independent
• OS manages computer resources.
• OS controls and coordinates the use of the computing
resources among the various users/programs:
– resource sharing among computer
users/programs
– OS creates resource abstraction
– protect users from each others

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

Basic Functions of Operating System


 Manages Resources (Processors, memory, timers, disks, mice, network, interfaces, printers, displays, …)

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

File system management


• OS responsibility for file management: Memory Management
– Manipulation of files and directories Process Management
– Allocate and deallocate memory space
– Map files onto (nonvolatile) secondary I/O System Management
– A processas requested
is a program in execution
storage - disks – • Unit
–Aofcomputer
work needs
Efficient I/O towhen
utilization interact
thewith the outside
memory
• OS responsibility for disk management: world:
– A processresource
needsiscertain
heavilyresources,
contended
– Free space management and storage – Console/terminal
– Keep
including CPU track
time,ofmemory,
which parts
files,of memory
allocation – Non-volatile secondary storage – disks
and I/Oare
devices,
currentlyto accomplish
being used andits task
by whom
– Disk scheduling – Networking
– Protection domain
• They are not all always together • The I/O system consists of:
– Not all files are mapped to secondary • OS responsibilities
– for process management:
A buffer-caching system
storage! o Process– creation and deletion
A general device-driver interface
– Not all disk space is used for the file o Process– scheduling,
Drivers for suspension, and
specific hardware devices
system! resumption
o Process synchronization, inter-
process communication
Simplified view of OS Process mode

Mode bit: Supervisor or User mode


• Supervisor mode
o Can execute all machine instructions
o Can reference all memory locations
• User mode
o Can only execute a subset of instructions
o Can only reference a subset of memory locations

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

Comparison between Windows and Linux OS


architecture
- Advanced Operating system
Handouts for Lecture 7 to 8
Computer Organization

Bootstrap loader

FIXED_LOC: // Bootstrap loader entry


point
load R1, =0
load R2, =LENGTH_OF_TARGET
// The next instruction is really more like
// a procedure call than a machine instruction
// It copies a block from
FIXED_DISK_ADDRESS
// to BUFFER_ADDRESS
read BOOT_DISK,
BUFFER_ADDRESS
loop: load R3,
[BUFFER_ADDRESS, R1]
store R3, [FIXED_DEST, R1]
incr R1
bleq R1, R2, loop
br FIXED_DEST

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

Device management Approaches


• Direct I/O – CPU software explicitly transfer data to and from the controller’s data registers
– Direct I/O with polling – the device management software polls the device controller status
register to detect completion of the operation; device management is implemented wholly in the
device driver, if interrupts are not used
– Interrupt driven direct I/O – interrupts simplify the software’s responsibility for detecting
operation completion; device management is implemented through the interaction of a device
driver and interrupt routine
• Memory mapped I/O – device addressing simplifies the interface (device seen as a range of memory
locations);
– Memory mapped I/O with polling – the device management software polls the device controller
status register to detect completion of the operation; device management is implemented wholly in
the device driver.
– Interrupt driven I/O – interrupts simplify the software’s responsibility for detecting operation
completion; device management is implemented through the interaction of a device driver and
interrupt routine
• Direct memory access – involves designing of hardware to avoid the CPU perform the transfer of
information between the device (controller’s data registers) and the memory

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

Device Device Device

Un-buffered I/O Reading into buffer A Reading into buffer B

Driver level Buffering Process Process

• This is generally called double buffering Driver Driver


• One buffer is for the driver to store the data while waiting for the higher A B A B

layers to read it buffers buffers

• 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

large enough to accommodate a block of data)


Device Device

Reading into driver buffer A Reading into driver buffer B


- Advanced Operating system
Handouts for Lecture 11,12
Device Driver in UNIX / LINUX

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.

Interfacing functions between user space and kernel space


The kernel offers several subroutines or functions in user space, which allow the end-user application programmer to
interact with the hardware.

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)

Interfacing functions between kernel space and the hardware device


There are also functions in kernel space which control the device or exchange information between the kernel and
the hardware.

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

Process : A Sequential program in execution

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

Thread : a program in execution; without a dedicated address space


OS memory protection is only applied to processes.

Why to use Thread?


Threads are used for parallelism/concurrency. But why not multiple
processes?
• Memory sharing.
• Efficient synchronization between threads
• Lightweight – less context switch overhead

• 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;

- Advanced Operating system


Handouts for Lecture 15 to 18
Synchronization
- Advanced Operating system
Handouts for Lecture 21 to 24
Remote Files
Objective: Network technology is the principal enabling technology for distributed computation. As a first
approach to distributed computing, OS d3esigners combined networks with the file abstraction to create the idea of
remote files.

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.

Topics to be covered in these sessions ;


• Information sharing in Networks
• Remote Disk systems, Mac systems
• Remote File Systems
o Block caching
o Crash Recovery
• File Level Caching
o Andrew File System
o Locus File system
• Directory systems and their implementations
o Directory services in Distributed architectures
o Namespaces, Global Namespaces
o Following Nomenclature for filenames
o File operations
o JNDI
- Advanced Operating system
Handouts for Lecture 25 to 29
Distributed Computing
Distributed computing is supported by creating new , specialized network protocols. It mainly focuses on
distributed primary memory concepts. Here, we will discuss how Os can allow threads on one machine to call
procedures or object methods on remote machine.

Distributed Computing

• Distributed Process Management


• Message Passing
o JMS (Java Message Passing System)
o MPI for distributed parallel computing
• Remote Procedural Call
o Implementation architecture for RMI
• Distributed Memory management
o Migration and Load balancing
• Java Remote Objects
o CORBA
o Role of ORB
o Marshalling and un-marshalling
o iiop protocol
• Concepts regarding cluster computing, grid computing

Vous aimerez peut-être aussi