Lecture Notes on Operating System, Lecture notes of Operating Systems

Lecture notes on Operating System, covering topics such as Introduction to Operating System, Process Management, Process Coordination, Memory Management, Storage Management, and Case Studies. The notes also include references to textbooks and reference books on the subject.

Typology: Lecture notes

2021/2022

Uploaded on 05/11/2023

geek45
geek45 🇺🇸

4.4

(10)

274 documents

1 / 98

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
LECTURE NOTES
ON
OPERATING SYSTEM
SUBJECT CODE: PCCS 4304 (3-0-0)
PREPARED BY
DR. PRASHANTA KUMAR PATRA
COLLEGE OF ENGINEERING AND TECHNOLOGY, BHUBANESWAR
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62

Partial preview of the text

Download Lecture Notes on Operating System and more Lecture notes Operating Systems in PDF only on Docsity!

LECTURE NOTES

ON

OPERATING SYSTEM

SUBJECT CODE: PCCS 4304 (3- 0 - 0)

PREPARED BY

DR. PRASHANTA KUMAR PATRA

COLLEGE OF ENGINEERING AND TECHNOLOGY, BHUBANESWAR

PCCS4304 OPERATING SYSTEM (3- 0 - 0) MODULE-I 12 Hours INTRODUCTION TO OPERATING SYSTEM: What is an Operating System? Simple Batch Systems, Multiprogramming and Time Sharing systems. Personal Computer Systems, Parallel Systems, Distributed Systems and Real time Systems. Operating System Structures: Operating System Services, System components, Protection system, Operating System Services, system calls PROCESS MANAGEMENT: Process Concept, Process Scheduling, Operation on Processes, Interprocess communication, Examples of IPC Systems, Multithreading Models, Threading Issues, Process Scheduling Basic concepts, scheduling criteria, scheduling algorithms, Thread Scheduling. MODULE-II 12 Hours PROCESS COORDINATION: Synchronization: The Critical section problem, Peterson’s solution, Synchronization hardware, Semaphores, Classical problems of synchronization, Monitors. Deadlocks: System model, Deadlock Characterization Methods for Handling Deadlocks, Deadlock Prevention, Deadlock avoidance, Deadlock Detection, recovery from Deadlock. MEMORY MANAGEMENT: Memory Management strategies, Logical versus Physical Address space, swapping, contiguous Allocation, Paging, Segmentation. Virtual Memory: Background, Demand paging, performance of Demand paging, Page Replacement, Page Replacement Algorithms. Allocation of frames, Thrashing, Demand Segmentation. MODULE-III 11 Hours STORAGE MANAGEMENT: File System Concept, Access Methods, File System Structure, File System Structure, File System Implementation, Directory implementation, Efficiency and Performance, Recovery, Overview of Mass Storage Structure, Disk Structure, Disk Scheduling, Disk Management, Swap- Space Management, I/O System Overview, I/O Hardware, Application I/O Interface, Kernel I/O Subsystem, Transforming I/O Request to Hardware Operation. CASE STUDIES: The LINUX System, Windows XP, Windows Vista TEXT BOOK:

  1. Operating System Concepts – Abraham Silberschatz, Peter Baer Galvin, Greg Gagne, 8 th edition, Wiley-India, 2009.
  2. Mordern Operating Systems – Andrew S. Tanenbaum, 3 rd Edition, PHI
  3. Operating Systems: A Spiral Approach – Elmasri, Carrick, Levine, TMH Edition REFERENCE BOOK:
  4. Operating Systems – Flynn, McHoes, Cengage Learning
  5. Operating Systems – Pabitra Pal Choudhury, PHI
  6. Operating Systems – William Stallings, Prentice Hall
  7. Operating Systems – H.M. Deitel, P. J. Deitel, D. R. Choffnes, 3 rd Edition, Pearson

OS Definition  OS is a resource allocator o Manages all resources o Decides between conflicting requests for efficient and fair resource use  OS is a control program o Controls execution of programs to prevent errors and improper use of the computer Computer Startup  bootstrap program is loaded at power-up or reboot o Typically stored in ROM or EPROM, generally known as firmware o Initializes all aspects of system o Loads operating system kernel and starts execution

Computer System Organisation  One or more CPUs, device controllers connect through common bus providing access to shared memory  Concurrent execution of CPUs and devices competing for memory cycles  I/O devices and the CPU can execute concurrently  Each device controller is in charge of a particular device type  Each device controller has a local buffer  CPU moves data from/to main memory to/from local buffers  I/O is from the device to local buffer of controller  Device controller informs CPU that it has finished its operation by causing an interrupt  Interrupt transfers control to the interrupt service routine generally, through the interrupt vector , which contains the addresses of all the service routines  Interrupt architecture must save the address of the interrupted instruction  Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt

 Magnetic disks – rigid metal or glass platters covered with magnetic recording material Direct Memory Access Structure  Used for high-speed I/O devices able to transmit information at close to memory speeds  Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention  Only one interrupt is generated per block, rather than the one interrupt per byte Storage Hierarchy  Storage systems organized in hierarchy o Speed o Cost o Volatility

Caching  Important principle, performed at many levels in a computer (in hardware, operating system, software)  Information in use copied from slower to faster storage temporarily  Faster storage (cache) checked first to determine if information is there o If it is, information used directly from the cache (fast) o If not, data copied to cache and used there  Cache smaller than storage being cached o Cache management important design problem o Cache size and replacement policy o Disk surface is logically divided into tracks , which are subdivided into sectors o The disk controller determines the logical interaction between the device and the computer Computer System Architecture  Most systems use a single general-purpose processor (PDAs through mainframes) o Most systems have special-purpose processors as well  Multiprocessors systems growing in use and importance o Also known as parallel systems, tightly-coupled systems o Advantages include  Increased throughput  Economy of scale  Increased reliability – graceful degradation or fault tolerance o Two types  Asymmetric Multiprocessing

o A subset of total jobs in system is kept in memory o One job selected and run via job scheduling o 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 o Response time should be < 1 second o Each user has at least one program executing in memory  process o If several jobs ready to run at the same time  CPU scheduling o If processes don’t fit in memory, swapping moves them in and out to run o Virtual memory allows execution of processes not completely in memory  Operating System Operation  Interrupt driven by hardware  Software error or request creates exception or trap o 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 o User mode and kernel mode o 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  Timer to prevent infinite loop / process hogging resources

o Set interrupt after specific period o Operating system decrements counter o When counter zero generate an interrupt o Set up before scheduling process to regain control or terminate program that exceeds allotted time OS Services  One set of operating-system services provides functions that are helpful to the user: o User interface - Almost all operating systems have a user interface (UI)  Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch o Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error) o I/O operations - A running program may require I/O, which may involve a file or an I/O device o File-system manipulation - The file system is of particular interest. Obviously, programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.  One set of operating-system services provides functions that are helpful to the user (Cont): o Communications – Processes may exchange information, on the same computer or between computers over a network

System Call  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 Program 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) Example  System call sequence to copy the contents of one file to another file

 Typically, a number associated with each system call o 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 o Just needs to obey API and understand what OS will do as a result call o 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) Types of system call  Process control  File management  Device management  Information maintenance

Fig: MS Dos structure Layered Approach  The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface.  With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers Fig: Layered System

Fig: UNIX system structure Micro Kernel Sructure  Moves as much from the kernel into “ user ” space  Communication takes place between user modules using message passing  Benefits: o Easier to extend a microkernel o Easier to port the operating system to new architectures o More reliable (less code is running in kernel mode) o More secure  Detriments: o Performance overhead of user space to kernel space communication Virtual Machne  A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware  A virtual machine provides an interface identical to the underlying bare hardware

Process State As a process executes, it changes state o new: The process is being created o running: Instructions are being executed o waiting: The process is waiting for some event to occur o ready: The process is waiting to be assigned to a processor o terminated: The process has finished execution Fig: Process Transition Diagram PCB: Process Control Block Information associated with each process  Process state  Program counter  CPU registers  CPU scheduling information  Memory-management information  Accounting information  I/O status information

Fig: PCB Context Switching  When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process via a context switch  Context of a process represented in the PCB  Context-switch time is overhead; the system does no useful work while switching  Time dependent on hardware support Process Scheduling Queues  Job queue – set of all processes in the system  Ready queue – set of all processes residing in main memory, ready and waiting to execute  Device queues – set of processes waiting for an I/O device  Processes migrate among the various queues