Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.

Similar presentations


Presentation on theme: "1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system."— Presentation transcript:

1 1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system Operating system design

2 2 System Structure Layered approach –Operating system divided into layers –Higher levels use only services of lower levels –Basic principle of abstract data types (classes) Figure 2.14

3 3 Original Unix O/S: Kernel approach Figure 2.13, p. 71 “monolithic structure”

4 4 Monolithic “structure” “an enormous amount of functionality … combined into one level [of abstraction in software]” (p. 71, Our text-- Silberschatz et al.) “… this approach might well be subtitled ‘The Big Mess.’ The structure is that there is no structure. The operating system is written as a collection of procedures, each of which can call any of the other ones whenever it wants to.” (p. 56, Tanenbaum, 2001, Modern Operating Systems, 2nd Ed).

5 5 Microkernel Approach More like a client-server system Kernel supports message passing –Plus some other low-level services such as interrupt handling, loading device drivers Much of former kernel runs in user mode (not kernel mode) –E.g., file system (server) may run in user mode Mach, QNX operating systems organized this way QNX is “real-time”; small (micro) kernel can be advantageous to real-time systems

6 6 Mac OS X: “Microkernel” Approach Figure 2.16

7 7 Solaris: Modular approach “Perhaps the best current methodology for operating-system design involves using object- oriented programming techniques to create a modular kernel” (p. 74) modules are typically dynamically loadable (e.g., Solaris, Linux, Mac OS X) Fig 2.15

8 Process Interfaces to the System In what we’ve been talking about so far, a process can either execute machine language code or it can make system calls What other kinds of process interfaces are possible? API interface Virtual machine interface 8

9 9 Virtual Machines Processes provided with an interface identical to the bare hardware Each process is provided with a (virtual) copy of the underlying computer E.g., IBM VM mainframe operating system Devices are an issue –e.g., Disks must be partitioned Each user runs an operating system on their virtual machine –Some instructions may run directly on hardware –Some instructions (e.g., I/O) are interpreted

10 10 Figure 2.17: System Models Non-virtual Machine Virtual Machine

11 11 Java Virtual Machine (JVM) Specification for an abstract computer –http://java.sun.com/docs/books/jvms/ –http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html Instructions specified as “bytecode”s Architecture neutral Java program code is compiled (javac) into files containing bytecode JVM includes –Class loader –Bytecode verifier –Bytecode interpreter

12 12 Operating System Design Design goals –User goals E.g., convenient, easy to use –System goals E.g., easy to design, implement, maintain; efficient Mechanism vs. Policy –Mechanisms determine how to do something Provided by the operating system E.g., ability to set the priority of a user process –Policies determine what will be done E.g., determining which processes get highest priority –Separation gives flexibility –See Solaris example p. 69

13 13 Services User interface Program execution: Processes Resource allocation I/O operations File-system manipulation Communications Protection & security Error detection Accounting Figure 2.1, p. 50 of text

14 Services - 1 User Interface –GUI and command line are the most common for general purpose operating systems Program execution –System must be able to load a machine language program into RAM memory and run that program –Why machine language? Resource allocation –Multiple processes or users: Need to share, allocate, and manage resources –Examples of types of resources: CPU cycles (time), main memory, files, I/O devices (printers, USB flash drives etc). 14

15 Services - 2 I/O operations –All I/O that a program does is typically carried out by the O/S –This is for efficiency and protection File-system manipulation –“Obviously, programs [in some operating systems] need to read and write files and directories” (p. 50) Communications –Between processes on the same computer and between processes across different computers –Shared memory & message passing: Two implementations 15

16 Services - 3 Protection & security –In multiuser systems, some people want to control access to their information –Generally, “when several separate processes execute concurrently, it should not be possible for one process to interfere with others or with the operating system itself” (p. 51) Error detection –“The operating system needs be constantly aware of possible errors” (p. 51) –Hardware errors include: power, memory, device errors –Software errors include: divide by 0, access of an illegal memory location Accounting –Which processes/users use which resources and for how long? –For statistics or for billing 16

17 17 What is a system call? A means for application programs to access operating system functionality Types of calls –Process control: E.g., create, load, execute –File operations: E.g., create, open, read, write –Device manipulation: E.g., request, read, write –Information: E.g., get or set process attributes –Communications: E.g., create connection, send or receive message

18 18 Figure 1.10: Transition from User to Kernel Mode

19 19 System Call Implementation For example? –E.g., file open, close, read or write ① Software interrupt CPU instruction is executed ② Execution control passes to an interrupt service routine in O/S; context switch is required ③ CPU mode bit is set to monitor (kernel) mode ④ Parameters of the software interrupt Indicate the type of system call (e.g., read or write) Parameters to the system call passed in registers, in a block of data, or the user stack ⑤ System call is executed E.g., kernel code runs Process is executing kernel code for duration of system call ⑥ Process is resumed (return from interrupt), back in user mode; context switch is required

20 20 Procedure Calls vs. System Calls Operating system System Call Return value(s) User process Libraries User process Libraries Procedure call is within the user process address space

21 21 System Programs Programs that provide system related services –Use operating system calls to provide operating system related functionality E.g., –Network communications such as http servers –File management: directory listing, copying files (cp on Unix) –User interface


Download ppt "1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system."

Similar presentations


Ads by Google