Rab Nawaz Khan Jadoon

Similar documents
Introduction: Context Switch

Process Management Rab Nawaz Jadoon

Operating Systems Overview. Chapter 2

Announcement. Exercise #2 will be out today. Due date is next Monday

Commercial Real-time Operating Systems An Introduction. Swaminathan Sivasubramanian Dependable Computing & Networking Laboratory

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Operating System. Operating Systems Structure Chapter 2. Services Provided by the OS. Evolution of an Operating System

Operating System Architecture. CS3026 Operating Systems Lecture 03

CSCE Introduction to Computer Systems Spring 2019

Why use an Operating System? Operating System Definition

OS Design Approaches. Roadmap. OS Design Approaches. Tevfik Koşar. Operating System Design and Implementation

Operating System. Operating System Overview. Structure of a Computer System. Structure of a Computer System. Structure of a Computer System

Threads Assistant Professor DCS Operating System Concepts

CSC Operating Systems Fall Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. August 27 th, 2009.

Announcements. Computer System Organization. Roadmap. Major OS Components. Processes. Tevfik Ko!ar. CSC Operating Systems Fall 2009

Process Description and Control. Chapter 3

Today: Computer System Overview (Stallings, chapter ) Next: Operating System Overview (Stallings, chapter ,

CSC 716 Advanced Operating System Fall 2007 Exam 1. Answer all the questions. The maximum credit for each question is as shown.

6.033 Spring Lecture #6. Monolithic kernels vs. Microkernels Virtual Machines spring 2018 Katrina LaCurts

Introduction. CS3026 Operating Systems Lecture 01

System Call. Preview. System Call. System Call. System Call 9/7/2018

Process Description and Control

Secondary Storage Management Rab Nawaz Jadoon

Operating Systems: Internals and Design Principles. Chapter 2 Operating System Overview Seventh Edition By William Stallings

CSE 410. Operating Systems

Major Requirements of an OS

Running Applications

Operating System Concepts Rab Nawaz Khan Jadoon

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University

Operating Systems Structure and Processes Lars Ailo Bongo Spring 2017 (using slides by Otto J. Anshus University of Tromsø/Oslo)

Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras

IT 540 Operating Systems ECE519 Advanced Operating Systems

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - II OS Structures. University at Buffalo. OS Design and Implementation

OS Design Approaches. Roadmap. System Calls. Tevfik Koşar. Operating System Design and Implementation. CSE 421/521 - Operating Systems Fall 2013

Process Scheduling Queues

Process Description and Control. Major Requirements of an Operating System

Interrupts Peter Rounce

Major Requirements of an Operating System Process Description and Control

Operating Systems. Operating System Structure. Lecture 2 Michael O Boyle

SMD149 - Operating Systems

Subject: Operating System (BTCOC403) Class: S.Y.B.Tech. (Computer Engineering)

Computer System Overview. Chapter 1

Operating systems Architecture

CPU Scheduling. Rab Nawaz Jadoon. Assistant Professor DCS. Pakistan. COMSATS, Lahore. Department of Computer Science

Input / Output. School of Computer Science G51CSA

Multiprocessor and Real- Time Scheduling. Chapter 10

OPERATING SYSTEM PROJECT: SOS

Real Time and Embedded Systems. by Dr. Lesley Shannon Course Website:

1/16/17. Computer Programs and Processes. PHYSICAL: damage from either tampering, misuse, theft of equipment, or any combination of these

1- Which of the following tasks is the operating system NOT responsible for? d) Coordinates communication between software applications and the CPU

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

Operating Systems. Lecture 3- Process Description and Control. Masood Niazi Torshiz

Operating System. Operating System Overview. Layers of Computer System. Operating System Objectives. Services Provided by the Operating System

Operating System Overview. Operating System

Computer System Overview

Lecture Topics. Announcements. Today: Uniprocessor Scheduling (Stallings, chapter ) Next: Advanced Scheduling (Stallings, chapter

Slide 6-1. Processes. Operating Systems: A Modern Perspective, Chapter 6. Copyright 2004 Pearson Education, Inc.

Process Description and Control

CPU Structure and Function

3.1 Introduction. Computers perform operations concurrently

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

Dr. D. M. Akbar Hussain DE5 Department of Electronic Systems


Operating Systems. Computer Science & Information Technology (CS) Rank under AIR 100

CS370 Operating Systems

CSC 2405: Computer Systems II

CSC Operating Systems Spring Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. January 17 th, 2007.

Announcements. Operating System Structure. Roadmap. Operating System Structure. Multitasking Example. Tevfik Ko!ar

Operating system organizaton

Hardware OS & OS- Application interface

COS 318: Operating Systems

Operating System: an Overview. Lucia Dwi Krisnawati, MA

Definition: An operating system is the software that manages resources

Kernel Types Simple OS Examples System Calls. Operating Systems. Autumn CS4023

Today s Topics. u Thread implementation. l Non-preemptive versus preemptive threads. l Kernel vs. user threads

Chapter 3 Process Description and Control

Threads Chapter 5 1 Chapter 5

Q.1 Explain Computer s Basic Elements

Operating Systems Overview. Chapter 2

2. The system of... generally ran one job at a time. These were called single stream batch processing.

Computer System Overview

Operating System. Chapter 4. Threads. Lynn Choi School of Electrical Engineering

Computer System Overview

Operating Systems Structure. Otto J. Anshus

13-2 EE 4770 Lecture Transparency. Formatted 8:18, 13 March 1998 from lsli

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Interrupts Peter Rounce - room 6.18

Announcements. Reading. Project #1 due in 1 week at 5:00 pm Scheduling Chapter 6 (6 th ed) or Chapter 5 (8 th ed) CMSC 412 S14 (lect 5)

Sistemi in Tempo Reale

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

TYPES OF OPERATING SYSTEMS. Dimple Juneja

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

Computer System Overview OPERATING SYSTEM TOP-LEVEL COMPONENTS. Simplified view: Operating Systems. Slide 1. Slide /S2. Slide 2.

Process Time. Steven M. Bellovin January 25,

Chapter 8: Main Memory

Process Description and Control. Chapter 3

Process Description and Control

CSC227: Operating Systems Fall Chapter 1 INTERRUPTS. Dr. Soha S. Zaghloul

Solved MCQs on Operating System Principles. Set-1

EEE 435 Principles of Operating Systems

Transcription:

OS Kernel, Instruction Execution and Interrupt Processing Rab Nawaz Khan Jadoon DCS COMSATS Institute of Information Technology Lecturer COMSATS Lahore Pakistan Operating System Concepts

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. 2

OS Kernel Types of kernels May be classified mainly in two categories Monolithic (Mono single, Lithic 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 3

OS 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. LINUX follows the Monolithic Modular Approach. 4

MicroKernels 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 the buffer overflow, then only the networking services memory would be corrupted, leaving the rest of the system still functional. 5

The important features include, Managing memory protection Process scheduling Inter process communication (IPC) Microkernel Set of methods for the exchange of data among multiple threads in one or more processes. QNX follows the microkernel approach. QNX is a commercial Unix-like real-time operating system (RTOS), aimed primarily at the embedded systems market, i.e. BlackBerry 6

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. 7

Instruction Execution(IE) The process in which CPU reads instruction from memory and execute each instruction, called IE. 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. 8

Instruction execution cycle 9

Instruction execution cycle 10

There are two types of jobs I/O limited jobs Jobs types 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; For (k=0;k<=5;k++) {sum=sum+k; cout<<sum;} 11

Interrupt Interrupt processing 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. 12

There are six interrupt classes, Supervisor Call Interrupt (SVC) Interrupt classes It is user generated request for a particular system service such as performing IO, obtaining more storage, or communication with system operator. It secure the OS from user interruption. When a user request for a service it must be handled through a SVC. I/O interrupt These are initiated by IO hardware. They signal to the CPU that device has changed. They are caused when an IO completes, IO error occur or when a device ready etc/. 13

External interrupts Interrupt classes These are caused by various events like expiration of quantum. Or a signal from processor to another on a multiprocessor environment. Program check interrupt When machine language instructions are executed, Division by zero, overflow, underflow etc. Restart When the user press the restart button of the computer. Or when a restart instruction arrives from another processor on multiprocessor system. 14

Machine check interrupt Interrupt classes These are caused by the malfunctioning of the hardware. 15

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 16

Context switching When an interrupt occurs, the operating system saves the interrupted process and shift the control to the appropriate first level interrupt handler (FLIH) This is handled through context switching Program Status Word (PSW) Control the order of instruction execution and contains the various sates of a process. There are three types of PSW Current PSW, New PSW and Old PSW. 17

Current PSW Context switching The address of the next instruction to be executed are stored/kept in current PSW, which indicated the interrupt type currently enabled or disabled. The CPU allows enabled interrupts to occur. On a uniprocessor system there is only one current PSW, but there are six new PSWs for each interrupt class and six old PSWs, one for each Interrupt class. 18

New PSW Context switching It contains the memory address at which the interrupt handler for that interrupt type resides. When an interrupt occur, then the H/W automatically switches PSWs by, Storing the current PSW in the old PSW for that type of interrupt. Storing the new PSW for that type of interrupt into the current PSW. After this swap the current PSW now contains the address of the appropriate IH. The IH executes and process the interrupt. 19

Context switching When the processing of the interrupt completes, the CPU is dispatched to either the interrupted process or to the highest priority ready process. 20

21