Docsity

Operating System Design and Implementation: A Comprehensive Guide - Prof. T. Kosar, Study notes of Operating Systems

Partial preview of the text

Download Operating System Design and Implementation: A Comprehensive Guide - Prof. T. Kosar and more Study notes Operating Systems in PDF only on Docsity!

1

CSC 4103 - Operating Systems Spring 2007

Tevfik Koşar

Louisiana State University January 23rd, 2007

Lecture - III

  • OS Design & Implementation
    • Processes

2

Roadmap

  • OS Design and Implementation
    • Different Design Approaches
    • Virtual Machines
  • Processes
    • Basic Concepts
    • Context Switching
    • Process Queues
    • Process Scheduling
    • Process Termination

3

Operating System Design and Implementation

  • Start by defining goals and specifications
  • Affected by choice of hardware, type of system
    • Batch, time shared, single user, multi user, distributed
  • User goals and System goals
    • User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast
    • System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error- free, and efficient
  • No unique solution for defining the requirements of an OS  Large variety of solutions  Large variety of OS

4

Operating System Design and Implementation (Cont.)

  • Important principle: to separate policies and mechanisms Policy: What will be done? Mechanism: How to do something?
  • Eg. to ensure CPU protection
    • Use Timer construct (mechanism)
    • How long to set the timer (policy)
  • The separation of policy from mechanism is allows maximum flexibility if policy decisions are to be changed later

7

MS-DOS Layer Structure

8

UNIX

  • UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX OS consists of two separable parts - Systems programs - The kernel - Consists of 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

9

UNIX System Structure

10

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 - GLUnix: Global Layered Unix

13

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 more flexible
    • Any module can call any other module

14

Solaris Modular Approach

15

Mac OS X Structure - Hybrid

  • BSD: provides support for command line interface, networking, file system, POSIX API and threads
  • Mach: memory management, RPC, IPC, message passing

16

Virtual Machines

  • 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
  • The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory

19

Virtual Machines (Cont.)

  • The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines. This isolation, however, permits no direct sharing of resources.
  • A virtual-machine system is a perfect vehicle for operating-systems research and development. System development is done on the virtual machine, instead of on a physical machine and so does not disrupt normal system operation.
  • The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine

20

VMware Architecture

21

The Java Virtual Machine

22

Processes

25

Process Control Block (PCB)

Information associated with each process

  • Process state
  • Program counter
  • CPU registers
  • CPU scheduling information
  • Memory-management information
  • Accounting information
  • I/O status information

26

Context Switch

  • 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
  • Context-switch time is overhead; the system does no useful work while switching
  • Time dependent on hardware support

27

CPU Switch From Process to Process

28

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

31

Schedulers

  • Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue
  • Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU

32

Schedulers (Cont.)

  • Short-term scheduler is invoked very frequently (milliseconds) ⇒ (must be fast)
  • Long-term scheduler is invoked very infrequently (seconds, minutes) ⇒ (may be slow)
  • The long-term scheduler controls the degree of multiprogramming
  • Processes can be described as either:
    • I/O-bound process – spends more time doing I/O than computations, many short CPU bursts
    • CPU-bound process – spends more time doing computations; few very long CPU bursts long-term schedulers need to make careful decision

33

Addition of Medium Term Scheduling

  • In time-sharing systems: remove processes from memory “temporarily” to reduce degree of multiprogramming.
  • Later, these processes are resumed  Swaping

34

Process Creation

  • Parent process create children processes, which, in turn create other processes, forming a tree of processes
  • Resource sharing
    • Parent and children share all resources
    • Children share subset of parent’s resources
    • Parent and child share no resources
  • Execution
    • Parent and children execute concurrently
    • Parent waits until children terminate

37

A tree of processes on a typical Solaris

  • sched: root process for OS
  • pageout: manages memory
  • fsflush: manages file system
  • init: root for user processes
  • inetd: Networking
  • dtlogin: user login screen
  • …

 Unique process id’s

38

Any Questions?

Hmm.. Hmm..

39

Reading Assignment

  • Read chapter 3 from Silberschatz.

40

Acknowledgements

  • “Operating Systems Concepts” book and supplementary material by Silberschatz, Galvin and Gagne.