Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCE451/851 Introduction to Operating Systems https://piazza.com/unl/fall2016/csce451/home.

Similar presentations


Presentation on theme: "CSCE451/851 Introduction to Operating Systems https://piazza.com/unl/fall2016/csce451/home."— Presentation transcript:

1 CSCE451/851 Introduction to Operating Systems http://cse.unl.edu/~ylu/csce451 https://piazza.com/unl/fall2016/csce451/home

2 Chapter 1 -Introduction What is an operating system? Interface between application programs and hardware Basic purpose of an operating system? Provide services to application programs Control functioning of hardware From a user’s point of view Ease of use maximize work (or play) that user performs From a system’s point of view Resource allocator

3 Components of a Computer System user1user2user n applications editoriecalcapp x Operating System hardware

4 1.2 Computer System Organization Most (if not all) modern CPU design is based on interrupts The CPU has various lines thru which a signal can be sent (interrupt) Interrupts can originate from hardware, cpu(trap), software(system call) Interrupts are provided as a way to improve processor performance Hardware interrupts can happen very frequently and must be handled promptly and efficiently

5 Handling an Interrupt Interrupt vector – an array of pointers to interrupt service routines indexed by the interrupt number When the CPU is interrupted: CPU saves address of interrupted instruction Invokes interrupt service routine whose address is stored in the Interrupt vector After the interrupt is serviced, the saved instruction address (and state) is restored and CPU resumes

6 Program Flow of Control

7 I/O Structures (1.2.3) A large part of operating system code is dedicated to managing I/O Reliability Performance Various types of devices available I/O is achieved through synchronization between Operating system code called device drivers Device controllers which transfer data between hardware and internal buffers Interrupts which invoke the correct device drivers

8 Device Controller Interface Status Instruction Data Data Data n-1 Logic.. PrimaryMemory Cpu Dev. Ctrlr. Device busydone Error codes..

9 I/O Structures (Character I/O) Example of slow input device-keyboard DC loads data register and interrupts CPU CPU invokes DD - Interrupt Vector DD fetches data from DC data register and transfers data to memory location Example of serial output device-printer OS Invokes DD DD loads data/instruction register on DC DC interrupts CPU when its done DD checks status registers, raises error or loads next data/instruction on DC

10 I/O Structure – Block Devices Character I/O is not effective enough for bulk data movement, Disks etc. An alternative to character I/O is block I/O (DMA) O/S sets up registers (instruction, buffer address, size etc.) in the DC DC transfers data directly to memory, interrupts CPU only to signal completion/error

11 Interrupt I/O vs. Direct Memory Access PrimaryMemory Cpu Dev. Ctrlr. Device PrimaryMemory Cpu Device Input LOAD COMMAND* INTERRUPT CPU GET STATUS XFER DATA Output LOAD COMMAND INTERRUPT CPU GET STATUS XFER DATA Input/Output LOAD COM., ADD. & SIZE Interrupt CPU on Completion GET STATUS XFER DATA

12 1.3 Computer System Architecture Self Read Must know the difference between Symmetric and Asymmetric systems.

13 The evolution of OS

14 1.4 Operating System Structure Multiprogramming - keep multiple jobs in memory, switching between them when the CPU is idle. Improve utilization of computer system Time sharing – switching between jobs based on timer Switches between jobs very frequently Each user/process is given the impression that they have sole access to the system Job 1 Job 2 Job 3 Job n OS

15 Multitasking and Timesharing First multitasking operating systems such as DOS were introduced to improve CPU efficiency Then Time shared systems such as Unix and Windows to allow multiple “simultaneous” program execution The O/S need to save the state of each program during interrupts, it needs to schedule the programs etc. To support the above and other issues, the concept of a process was created (Chapter 3)

16 1.5 Modes of Operation How do we prevent user processes from writing to Device Controller registers? Most systems support at least two modes of operation: the user mode and the kernel mode

17 Dual-Mode Operation All Operating System code is available when CPU is in Kernel mode Only User code is allowed to execute when CPU is in user mode What if a user process needs some OS service? System calls (S/C) provide the means for a user program to ask the OS to perform tasks reserved for the OS on the user program’s behalf USB Device Driver PCI Device Driver Create File S/C Read File S/C Write File S/C Create Process S/C Kill Process S/C Signal Process S/C Process Scheduler Virtual memory Mgr Inter Process Communication Locks & Synch.

18 Dual Mode Operation To support a stable and secure system, a dual-mode CPU was introduced Various instructions and memory addresses could only be accessed in Kernel mode To access service routines only available in the kernel (open a file, write a character to terminal, etc), a user process makes system calls Interrupt handlers are invoked to handle these system calls

19 Dual Mode Operation A system call allows a user process to request a protected service form the operating system The system call number along with arguments are stored in well defined registers and a special instruction is executed The cpu is placed in kernel mode and the system call service routine is executed The operating system determines the service the user process is requesting and verifies the arguments When complete, results are placed in the users process space and the cpu is placed back in user mode Execution continues with the next instruction

20 Dual Mode Operation The CPU is placed in kernel mode when an interrupt/trap/system call is received User process Execute Sys Call resume user process call sys call mode bit = 0 return mode bit = 1 user mode mode bit=1 kernel mode mode bit=0

21 The Timer The CPU timer interrupts the CPU during predetermined intervals Most timers are variables and can be set to interrupt the CPU after the user process has executed for a predetermined amount of time Instructions that update the timer must be privileged instructions Ensures that the OS maintains control of the CPU OS always sets time before turning over control to user

22 Other O/S Responsibilities Discuss tasks the operating system would be responsible for each of the subsystems listed below Memory management (Chap 1.7) Process management (Chap 1.6) Storage management (Chap 1.8) Protection and Security (Chap 1.9)

23 Reading Assignment. By this Friday Read Chapter 2


Download ppt "CSCE451/851 Introduction to Operating Systems https://piazza.com/unl/fall2016/csce451/home."

Similar presentations


Ads by Google