1 / 50

Lecture 4: Operating System Structures

Lecture 4: Operating System Structures. Joe McCarthy. Outline. More examples fork, pipe, dup2 Chapter 2: Operating Systems Structures Next time Chapter 3: Processes. More examples. C++ programs using fork(), pipe(), dup2() testpipe[0-2].cpp Send “hello” through pipe to STDOUT

ramonn
Télécharger la présentation

Lecture 4: Operating System Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 4:Operating System Structures Joe McCarthy CSS 430: Operating Systems

  2. Outline • More examples • fork, pipe, dup2 • Chapter 2: Operating Systems Structures • Next time • Chapter 3: Processes CSS 430: Operating Systems

  3. More examples • C++ programs using fork(), pipe(), dup2() • testpipe[0-2].cpp • Send “hello” through pipe to STDOUT • Differences: • hardcoded string vs. arg, write() vs execlp() • pipedup2[a-d].cpp • Using system calls to do ‘ps –A | tr a-z A-Z’ • Differences • Parent vs. child calling ps vs. tr • Using read() & write() vs. execlp() for tr • Linked from prog1b assignment page: • http://courses.washington.edu/css430/joemcc/prog/prog1b.html CSS 430: Operating Systems

  4. Chapter 2: Operating-System Structures

  5. A View of Operating System Services

  6. System Calls 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) Why use APIs rather than system calls? (Note that the system-call names used throughout this text are generic)

  7. Example of System Calls • System call sequence to copy the contents of one file to another file

  8. Example of System Calls • System call sequence to copy the contents of one file to another file

  9. Example of Standard API Consider the ReadFile() function in the Win32 API—a function for reading from a file A description of the parameters passed to ReadFile() HANDLE file—the file to be read LPVOID buffer—a buffer where the data will be read into and written from DWORD bytesToRead—the number of bytes to be read into the buffer LPDWORD bytesRead—the number of bytes read during the last read LPOVERLAPPED ovl—indicates if overlapped I/O is being used

  10. API – System Call – OS Relationship

  11. Standard C Library Example • C program invoking printf() library call, which uses write() system call

  12. System Call Parameter Passing • Often, more information is required than simply identity of desired system call • Exact type & amount of information vary according to OS & call • Three general methods used to pass parameters to the OS

  13. System Call Parameter Passing • Often, more information is required than simply identity of desired system call • Exact type & amount of information vary according to OS & call • Three general methods used to pass parameters to the OS • Simplest: pass the parameters in registers • In some cases, may be more parameters than registers • Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register • This approach taken by Linux and Solaris • Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system • Block and stack methods do not limit the number or length of parameters being passed

  14. Parameter Passing via Table

  15. Types of System Calls Process control File management Device management Status Information Communications Protection

  16. Process Control

  17. Process Control • End, abort • Load, execute • Create process, terminate process • Get process attributes, set process attributes • Wait for time • Wait for event, signal event • Allocate memory, free memory

  18. File Management

  19. File Management • Create file, delete file • Open, close • Read, write, reposition • Get file attributes, set file attributes

  20. Device Management

  21. Device Management • Request device, release device • Read, write, reposition • Get device attributes, set device attributes • Logically attach (mount) or detach (unmount) devices

  22. Information Maintenance

  23. Information Maintenance • Get time or date, set time or date • Get system data, set system data • Get process, file or device attributes • Set process, file or device attributes

  24. Communications

  25. Communications • Create, delete communication connection • Send, receive messages • Transfer status information • Attach or detach remote devices

  26. Windows & Unix System Calls

  27. MS-DOS execution (a) At system startup (b) running a program

  28. FreeBSD Running Multiple Programs

  29. OS Design & Implementation • Important distinction: • Policy: What will be done? • Mechanism: How to do it? • Benefits: • Maximum flexibility • Policy changes need not entail mechanism changes & vice versa

  30. Simple Structure MS-DOS Goal: most functionality in the least space Not divided into modules Interfaces & levels of functionality not well separated

  31. Layered Approach • Modularity: • Each layer (level) uses functions & services only from layer(s) directly below • Provides functions & services only to layer(s) directly above

  32. Traditional UNIX System Structure

  33. UNIX • Two components • Systems programs • ls, rm, cp, mv, ps, grep, wc, … • The kernel • Everything below the system-call interface and above the physical hardware • Provides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level

  34. Microkernel System Structure • Moves as much from the kernel into “user” space • Communication takes place between user modules using message passing • Benefits: • Easier to extend a microkernel • Easier to port the operating system to new architectures • More reliable (less code is running in kernel mode) • More secure • Detriments: • Performance overhead of user space to kernel space communication

  35. Mac OS X Structure

  36. Modules Most modern operating systems implement kernel modules Uses object-oriented approach Each core component is separate Each talks to the others over known interfaces Each is loadable as needed within the kernel Overall, similar to layers but with more flexible

  37. Solaris Modular Approach

  38. Virtual Machines A virtual machinetakes 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. The operating system hostcreates the illusion that a process has its own processor and (virtual memory). Each guest is provided with a (virtual) copy of underlying computer.

  39. Virtual Machines (a) Nonvirtual machine (b) virtual machine

  40. Solaris 10 with Two Containers

  41. VMware Architecture

  42. Java • Java consists of: • Programming language specification • Application programming interface (API) • Virtual machine specification

  43. The Java Development Kit

  44. Cloud Computing CSS 430: Operating Systems

  45. http://news.cnet.com/8301-13953_3-9917409-80.html CSS 430: Operating Systems

  46. Amazon Web Services CSS 430: Operating Systems

  47. CSS 430: Operating Systems

  48. CSS 430: Operating Systems

  49. The Cost of Convenience CSS 430: Operating Systems

  50. For next time • Readings • Chapters 3 CSS 430: Operating Systems

More Related