Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 I/O Devices Controller: physically controls the devices Devices are diverse and complicated Present simpler interface to OS E.g, convert a linear sector.

Similar presentations


Presentation on theme: "1 I/O Devices Controller: physically controls the devices Devices are diverse and complicated Present simpler interface to OS E.g, convert a linear sector."— Presentation transcript:

1 1 I/O Devices Controller: physically controls the devices Devices are diverse and complicated Present simpler interface to OS E.g, convert a linear sector number to number of cylinder, sector and head. Device driver: software talks to a controller Installation of drivers Re-link kernel with new driver, reboot Register driver in system file, reboot Install on-the-fly, PNP, NO reboot device controller driver Operating system

2 2 Handle I/O: Busy Waiting User programKernelDriver I/O device Issue a system call (TRAP) Call driver Start I/O PollingDo I/O Put data Return control to caller Continue TIMETIME CPU Wasted

3 3 An Example // p is the buffer for (i=0; i<count; i++){ while (*printer_status_reg!=READY); *printer_data_register=p[i]; } return_to_user(); // loop on every character // loop until ready // output one character

4 4 I/O by Interrupt Driver tells controller what to do by writing its device registers. Then the controller starts the device. Controller finishes reading/writing, and then signals the interrupt controller If interrupt controller can accept the interrupt, it informs CPU Interrupt controller puts the number of device on the bus, CPU read it CPU Interrupt controllerDisk controller Disk drive 1 2 3 4

5 5 Interrupt-Driven I/O Print system call enable_interrupts(); *printer_data_register=p[0]; scheduler(); Interrupt service procedure if (count==0){ unblock_user(); } else { *printer_data_register=p[I]; count--; i++; } acknowledge_interrupt(); return_from_interrupt(); Interrupt occurs on every character!

6 6 Direct Memory Access (DMA) User programKernel I/O device & memory Issue a system call Set up DMA chip Suspended Run other programs I/O directly Issue interrupt when finish Set the program status as “ready” Ready to continue

7 7 I/O Using DMA Too many interrupts in interrupt-driven I/O DMA reduces # of interrupts from 1/char to 1/buffer printed Print system call copy_from_user(buffer, p, count); set_up_DMA_controller(); scheduler(); Interrupt service procedure acknowledge_interrupt(); unblock_user(); return_from_interrupt();

8 8 Advanced Computer With Multiple Buses IDE bus SCSI bus USB bus Level 2 cache CPU PCI bridge Main memory Cache busLocal busMemory bus PCI bus Available PCI slot SCSIUSB ISA bridge IDE disk Graphics adaptor Monitor ISA bus MouseKeyboard ModemSound cardPrinter Available ISA slot

9 Chapter 2 Processes and Threads

10 10 Outline Processes Threads Inter-process communication (IPC) Classical IPC problems Scheduling

11 11 Process A program in execution a single instance of an executable program User enters a command, invokes a program, while this program is executing it is called a process E.g, when a user types the command “ls”, the UNIX system creates a process for this command. Different processes running different programs: Word, Excel Different processes running same programs: multiple web-browsers in a PC

12 12 Much More Than A Program Address space contain the executable program, the program’s data, and its stack. I/O devices associated Files opened Execution State: Registers, e.g., PC, PSW, SP, …

13 13 Process Vs. Programs: An Analogue A baker (CPU) uses a recipe (program) to transform the baking ingredients (input data), with the aid of cooking utensils and appliances (resources), into a cake (output). We recognize this entire activity as the process - an abstraction of an executing recipe.

14 14 Process Vs. Program Program is a script, while process is an activity (execution) based on this script. Cake recipe  program, baking cake based on the recipe  process Different processes may share the same program One copy of script, but multiple executions Process is more than a script Script, input, output, state, etc.

15 15 Information About Process Process table in operating systems One entry for each process in existence Process ID, program counter, working directory, registers, etc. Core image: process address space Instruction codes and data Process information = Process table entry + core image

16 16 Interleaving Execution of Processes More than one process exist. CPU switches from process to process. Process A Process B Process A Process C Process B Process C Which process to run next? Process switching Time

17 17 Pseudo-parallelism At any instant, the CPU is running only one process. In the course of 1 second, it may work on several different processes. The illusion of parallelism The true hardware parallelism: multi-processor Multi-programming CPU switches back and forth between processes.

18 18 Different Points of View Process D  C  B  A  Time  Running independently of each other. Each process has its own logical program counter (PC). But only one physical PC in CPU. A  B  C  D  E  From User From OS t1

19 19 Process Creation – When? System initialization Created by another process User request Initialization of a batch job

20 20 Process Creation in System Initialization Foreground processes Interact with users E.g., UNIX shell Background processes Not associated with particular user Daemons: have some specific functions E.g., Accepting emails, accepting web page request


Download ppt "1 I/O Devices Controller: physically controls the devices Devices are diverse and complicated Present simpler interface to OS E.g, convert a linear sector."

Similar presentations


Ads by Google