Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operating - System Structures

Similar presentations


Presentation on theme: "Operating - System Structures"— Presentation transcript:

1 Operating - System Structures
Chapter 1& 2 Operating - System Structures Dr. Amjad Ali & Yella Mehrooz

2 Computer-System Architecture
Most systems contain a single general-purpose processor Few systems contain special-purpose processors as well Multiprocessors systems growing in use and importance Also known as parallel systems, tightly-coupled systems Advantages include: Increased throughput- more work done in less time Speed up ratio with N processor is not N Overhead of keep all component working correctly Contention for shared resources Economy of scale Increased reliability – graceful degradation or fault tolerance The ability of a system to maintain limited functionality even when a large portion of it has been destroyed or rendered inoperative

3 Computer-System Architecture
Multiprocessor systems are of two types: Asymmetric Multiprocessing– each processor assigned a specific task Master-slave relationship The tasks are strictly divided by their types on processors Typically, each processor has its own memory address space These features make asymmetric multiprocessing difficult to implement. Symmetric Multiprocessing (SMP)– each processor performs all tasks within the OS or they can do anything the others can.  All processor are peers Contain own set of registers and private or local caches Shared physical memory Asymmetric multiprocessing; one processor doing all I/O Symmetric multiprocessing

4 A Dual-Core Design Cores- Multiprocessor chips
on-chip communication is faster well suited for server (i.e., database, Web servers) Multicore CPUs appear to the operating system as N standard processors A dual-core design with two cores places on the same chip

5 Blade Servers Blade server is a stripped down  server computer with a modular design optimized to minimize the use of physical space and energy  Multiple processor boards, I/O boards, and networking boards are placed in the same chassis HP blade system c7000 enclosure (populated with 16 blades), with two 3U UPS units below.

6 Clustered Systems Another type of multiple-CPU system is clustered system Usually sharing storage via a storage-area network (SAN) Provides a high-availability service which survives failures Asymmetric clustering; One machine in hot-standby mode while the other is running the applications Symmetric clustering; multiple machines are running the applications as well as monitoring each other Some clusters are for high-performance computing (HPC) Applications must be written to use parallelization General structure of a clustered system

7 Operating System Structure
Multiprogramming required for better efficiency Single user cannot keep CPU and I/O devices busy all the time Multiprogramming organizes jobs (code and data) so CPU always has one to execute A subset of total jobs in system is kept in memory One job selected and run via job scheduling When it has to wait (for I/O for example), OS switches to another job Timesharing (multitasking) is logical extension, in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing Response time should be < 1 second Process; A program loaded into memory and executing Job Scheduling; Decision to load some jobs from all jobs residing in job pool CPU scheduling; Decision to execute a job among many jobs waiting for execution Swapping; processes are swapped in and out of main memory to the disk Virtual Memory; a technique that allows the execution of a process that is not completely in memory

8 Comparison Multiprogramming There is only one processor
More than one user It is the function of OS to share CPU time among all the users equally Example: A computer running Excel and Firefox simultaneously Multiprocessing Multiprocessing is the use of two or more CPUs within a single computer system Symmetric and asymmetric multiprocessing Multitasking There is only one processor and one user. User can activate more than one program/task at a time. OS schedule multiple jobs for their fair share processing. Multithreading Execute different parts of a program called threads at the same time Threads: The light wait processes which are independent part of a process or program.

9 Comparison Memory layout for Multiprogramming System
Multi-processing System Multi-tasking System Multithreading System

10 Operating-System Operations
Interrupt driven by hardware Software error or request creates exception or trap Division by zero, request for operating system service Other process problems include infinite loop, processes modifying each other or the operating system Dual-mode operation allows OS to protect itself and other system components User mode and Kernel mode Mode bit provided by hardware 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

11 System Calls 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 for UNIX, Linux, and Mac OS, and Java API for the Java virtual machine (JVM) Why use APIs rather than system calls? System calls Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use System calls differ from platform to platform. By using a stable API, it is easier to migrate your software to different platforms.

12 Example of System Calls
System call sequence to copy the contents of one file to another file

13 Example of Standard API

14 System Call Implementation
Typically, a number associated with each system call System-call interface maintains a table indexed according to these numbers The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values The caller need know nothing about how the system call is implemented Just needs to obey API and understand what OS will do as a result call Most details of OS interface hidden from programmer by API Managed by run-time support library (set of functions built into libraries included with compiler)

15 API – System Call – OS Relationship

16 Types of System Calls Process control end, abort load, execute
create process, terminate process get process attributes, set process attributes wait for time wait event, signal event allocate and free memory Dump memory if error Debugger for determining bugs, single step execution Locks for managing access to shared data between processes

17 Types of System Calls File management create file, delete file
open, close file read, write, reposition get and set file attributes Device management request device, release device get device attributes, set device attributes logically attach or detach devices

18 Types of System Calls (Cont.)
Information maintenance get time or date, set time or date get system data, set system data get and set process, file, or device attributes Communications create, delete communication connection send, receive messages if message passing model to host name or process name From client to server Shared-memory model create and gain access to memory regions transfer status information attach and detach remote devices

19 Types of System Calls (Cont.)
Protection Control access to resources Get and set permissions Allow and deny user access

20 Examples of Windows and Unix System Calls

21 Standard C Library Example
C program invoking printf() library call, which calls write() system call

22 Operating System Kernel
A kernel is a central component of an operating system. It acts as an interface between the user applications and the hardware. The sole aim of the kernel is to manage the communication between the software (user level applications) and the hardware (CPU, disk memory etc.). The main tasks of the kernel are : Process management Device management Memory management Interrupt handling, I/O communication, and File system.

23 Types of kernels Classified mainly in two categories
Monolithic (Mono means single, Lithic means layer) Micro Kernel. Monolithic Older approach Basic system services like process and memory management, interrupt handling etc. were packed into a single module in kernel space. Some serious problems like, Size was huge, Poor maintainability (bug fixing and addition of new features resulted in recompilation of the whole kernel code which could consume hours. E.g. MS-DOS

24 Types of kernels Micro Kernel
Modern Kernel approach (Modular Approach) Kernel consists of different modules which can be dynamically loaded and un-loaded. Easy extension of OS’s capabilities. Maintainability became so easy as only the concerned module needs to be loaded and unloaded every time if there is change or bug fix in a particular module.

25 Micro Kernel This solve the problem of ever growing size of kernel code which we could not control in monolithic approach. This architecture allows some basic services like, Device driver management Protocol stack File system etc. to run in user space. It reduces the kernel size and increases the security and stability of OS e.g., if network service crashes due to buffer overflow, then only the networking services memory would be corrupted, leaving the rest of the system still functional.

26 Instruction Execution
Once a program is in memory it has to be executed. To do this, each instruction must be looked at, decoded and acted upon in turn until the program is completed. This is achieved by the use of what is termed the “instruction execution cycle”, which is the cycle by which each instruction in turn is processed.

27 Instruction Execution(IE)
The process in which CPU reads instruction from memory and execute each instruction The processing required for single instruction called instruction cycle. At the beginning of each instruction cycle, CPU fetches instruction from memory. PC holds the address of the next instruction to be executed. The fetched instruction is loaded into IR.

28 Jobs types There are two types of jobs I/O limited jobs
If in an application most of the tasks are I/O oriented then it is called I/O jobs. For (k=0;k<=5;k++) cout<<k; CPU limited jobs If a program only needs computation/processing then this is called CPU limited jobs. Sum=0; sum=sum+k;

29 Interrupt processing Interrupt
An Interrupt is an event that alters the sequence in which the processor executes instructions. When an I/O device completes an I/O operation some events occurs, The device issue an interrupt signal to the CPU. The processor finishes the execution of the current instruction before responding to the interrupt and save the state of the interrupted process. The OS analyses the interrupt and passes the control to the appropriate interrupt handling routine. The IHR handles the interrupt. The state of the interrupted process restored. The interrupted process executes.

30 Interrupt Handling While executing a process, an interrupt triggers.
It is handled by the IHR. The process starts its execution again. However what will happen if while handling an interrupt, another interrupt triggers? It can be handled using two approaches Sequential approach Nested approach

31 Sequential Interrupt Handling

32 Nested Interrupt Handling

33 Context switching A context switch is the computing process of storing and restoring the state (context) of a CPU so that execution can be resumed from the same point at a later time. This enables multiple processes to share a single CPU. The context switch is an essential feature of a multitasking operating system. Context switches are usually computationally intensive and much of the design of operating systems is to optimize the use of context switches


Download ppt "Operating - System Structures"

Similar presentations


Ads by Google