Operating Systems - PowerPoint PPT Presentation

1 / 53
About This Presentation
Title:

Operating Systems

Description:

some system calls can be accessed through the command interpreter (Shell) ... process creation; deletion; suspension. process synchronization; communication ... – PowerPoint PPT presentation

Number of Views:99
Avg rating:3.0/5.0
Slides: 54
Provided by: dramnon5
Category:

less

Transcript and Presenter's Notes

Title: Operating Systems


1
Operating Systems
  • Amnon Meisels Ehud Gudes
  • Office Hrs (314) (303)
  • Tuesday 1000-1200 Thursday
  • am_at_cs.bgu.ac.il os032/ ehud_at_cs.bg
    u.ac.il

2
Operating Systems (OS) - Syllabus
  • 1. Introduction - History Views Concepts
    Structure
  • 2. Process Management - Processes State
    Resources Threads Unix implementation of
    Processes
  • 3. Process Scheduling Paradigms Unix
    Modelling
  • 4. Process Synchronization - Synchronization
    primitives and their equivalence Deadlocks
  • 5. File Systems - Implementation Directory and
    space management Unix file system Distributed
    file systems (NFS)
  • 6. Memory Management - Virtual memory Page
    replacement algorithms Segmentation

3
OS - Syllabus (Contd.)
  • 7. Security - General policies and mechanisms
    examples of common problems protection models
    authentication
  • 8. Distributed Systems a few comments
  • Books
  • A. Tanenbaum Modern Operating Systems,
    Prentice-Hall, 2nd Edition, 2001
  • A. Silbetschatz et. al. Operating System
    Concepts (6th ed.), Addison Wesley,2001.
  • G. Nutt Operating Systems (a modern perspective)
    (2nd ed.), Addison Wesley, 1999.
  • W. Stallings Operating Systems (3rd ed.),
    Prentice-Hall, 1998.

4
Assignments and Grades
Date due Weight Subject Assignment
Week 4 5 A Toy Shell Practical 1
Week 8 15 Processes, Scheduling Practical 2
Week 12 10 Memory Management Practical 3
Week 9 15 up to Files Midterm
? 60 All Final
5
Introduction
  • Why do we need an operating system ?
  • Basis for all software
  • Simplifies access (for user processes) to
  • Memory
  • Permanent Data
  • i/o extended machine
  • Security and Protection
  • of executing user programs
  • of resources (devices)

6
Layered Hardware-Software Machine Model
7
What is an Operating System ?
  • The two Views of an Operating System
  • Top-down View
  • An Extended Machine
  • Bottom-up View
  • A Resource Manager

8
Operating Systems - Extended Machines
  • Problems
  • Bare machine has a complex structure
  • Processors
  • Many Devices
  • Primitive Instruction Set
  • Different for Different Machines
  • Solutions provided by the OS
  • Simple, easier to use interface
    (machine-independent)
  • Hiding of unnecessary details

9
Operating Systems as Resource Managers
  • Many Resources
  • Processors Memory
  • Disks Tapes Printers
  • Network interfaces Terminals
  • Controlled allocation of Resources among
  • Users Programs Processors
  • Control means sharing/multiplexing, monitoring,
    protection, report/payment

10
Multiprogramming Why how its possible?
  • CPU much faster than I/O
  • Memory large enough (512K!)
  • requires protection!
  • Scheduler which manages flow of jobs in and out
  • and shares CPU between jobs requires
    Timer
  • Spooler which takes care of slow I/O (e.g.
    printing).

11
Some relevant Hardware aspects
(a)
(b)
  • (a) Steps in starting an I/O device and getting
    interrupt
  • (b) How the CPU is interrupted

12
Memory Protection
  • Minimal protection must include the interrupt
    vector and service routines
  • General memory protection can use two registers
    -
  • base register - smallest legal address
  • limit register - size
  • memory outside the range is protected
  • Hardware performs these checks in all user-mode
    memory references
  • The load instructions for the two registers are
    privileged
  • In supervisor mode the OS has unrestricted
    access to all memory

13
Memory Protection
14
Memory protection (Cont.)
  • One base-limit pair and two base-limit pairs

15
User mode lt--gt Privileged mode (I/o)
  • All I/o instructions are privileged instructions
  • I/o devices and cpu can execute concurrently
  • cpu moves data main memory --gt buffers of
    device controllers
  • I/o itself is from device to controllers buffer
  • Device controllers interrupt upon completion
  • Interrupts or Traps enable mode switching..
  • control to interrupt service routine (interrupt
    vector)
  • Architecture saves address of interrupted
    instruction
  • Operating systems are interrupt-driven

16
Interrupts part of fetch-and-execute
  • While (halt flag not set during execution) /
    every fetch-and-execute/ IR
    memoryPCexecute(IR)PCIf(Interrupt_Reques
    t) memory0 PC PC memory1
  • Interrupt handlers loop over all device numbers
    and call the device_handler for which a flag done
    is raised
  • The interrupt handling routine uses a
    disable_interrupts instruction to avoid losing
    data while processing an interrupt request
  • Hardware may lose queuing interrupts, when the
    Interrupt_Disabled flag is raised and an
    interrupt occurs

17
(No Transcript)
18
Processes - a central concept
  • Programs in Execution
  • Timesharing -
  • Process Suspension
  • Process Table
  • Core image
  • Process Tree
  • Signals
  • Uids - Protection...

19
Operating System Concepts
  • A process tree
  • A created two child processes, B and C
  • B created three child processes, D, E, and F

20
Operating System Concepts
  • Two processes connected by a pipe

21
Files non volatile data
  • File types and operations on files
  • Directories - hierarchical structure
  • Working directories

22
Files non volatile data (cont.)
  • Protection and Security
  • Unix - user group other (rwx bits)
  • File descriptors (handles)
  • i/o as a special file
  • Block Character special files
  • Standard input output error the idea of Late
    binding
  • Pipes

23
Operating system concepts System calls
  • An interface from privileged or system mode to
    user mode (user programs)
  • System calls
  • create, delete, use various objects
  • Examples (Unix)
  • fdopen(file_name, mode)
  • close(fd) kill(pid,sig) fork()

24
A word on System Calls
  • Look like standard procedure calls
  • put parameters in Registers and TRAP
  • operation is performed in privileged mode
  • some system calls can be accessed through the
    command interpreter (Shell)
  • redirection gt
  • pipe
  • Do not wait for offspring process

25
Steps in Making a System Call
  • There are 11 steps in making the system call
  • read (fd, buffer, nbytes)

26
Some System Calls For Process Management
27
Some System Calls For File Management
28
Some System Calls For Directory Management
29
Some System Calls For Miscellaneous Tasks
30
System Calls
  • Some Win32 API calls

31
The Shell Commands Language
  • sort lt file1 gt file2
  • cat file1 sort lpr
  • The Shell is a process which executes its
    commands as offspring processes
  • Processes may call shell commands by using the
    system system call

32
Shell structureParent child
  • A stripped down shell
  • while (TRUE) / repeat forever /
  • type_prompt( ) / display prompt /
  • read_command (command, parameters) / input
    from terminal /
  • if (fork() ! 0) / fork off child process
    /
  • / Parent code /
  • waitpid( -1, status, 0) / wait for
    child to exit /
  • else
  • / Child code /
  • execve (command, parameters, 0) / execute
    command /

33
Initializing a (user) shell
  • The init program runs getty on all ports
  • Detecting a terminal getty runs login
  • Typing in a user name and a password login
    checks the passwd file and if correct runs a
    shell the one specified in the UID entry
  • The shell is run with that user ID environment
    parameters
  • The user process runs the shell

34
Running user commands
  • User types grep some_word file_name
  • Shell parses the command, inserts the strings
    grep, some_word, file_name into argv and argc
  • Next, the shell uses fork() to create a process
    (same user ID)
  • Now, it takes the executable name grep and the
    arguments, all from argv, and uses execve() or
    similar system calls to run the grep executable
  • Normally the shell uses the wait() system call to
    be rerun after grep exits one user process
    running

35
Small-Shell smash
  • Your assignment is to build a program smash'
    that will implement the following shell services
  • Run programs in foreground and background
  • List all processes that currently run in the
    background.
  • Kill a process running in the background.
  • Kill or suspend programs running in foreground
    mode using signals.
  • Move programs that run in foreground mode to
    background mode and vice versa.

36
OS - Main Components
  • Process management
  • process creation deletion suspension
  • process synchronization communication
  • Main-memory management
  • Manage used parts and their current users
  • Select processes to load
  • Allocate memory to running processes
  • Secondary storage management
  • Free-space management
  • Storage allocation

37
OS - Main Components (cont.)
  • File system management
  • File directory creation deletion
  • File manipulation primitives
  • Mapping files onto secondary storage
  • I/o system management
  • general device-driver interface
  • Drivers for specific hardware devices
  • Protection system
  • Distinguish between authorized and unauthorized
    usage
  • Provide means of enforcement

38
OS - Main Components (cont.)
  • Networking
  • A distributed system is a collection of
    processors that do not share memory or a clock
  • The processors are connected through a
    communication network
  • Provides user access to various system resources
  • Command-interpreter System
  • control statements that deal with process
    creation and management I/o handling
    file-system access protection networking
  • The program that reads and interprets - shell (in
    Unix)

39
Operating system structure
  • Monolithic systems have little structure

Service Routines
Utility procedures
40
Virtual Machines
  • The extreme layered approach
  • Provide an interface identical to the underlying
    bare machine
  • OS creates multiple processes, each executing on
    its own processor and own (virtual) memory
  • Virtual machines provide complete protection of
    system resources - even separate resources
  • Difficult to implement, due to the effort
    required to provide an exact duplicate of the
    underlying machine
  • Recent use run MS-DOS on top of Windows

41
Virtual Machines
42
Virtual Machines
  • Virtual machine monitors for operating systems

System call
System call
CMS
Trapped
CMS
CMS
VM/370
Trapped
370 Bare Hardware
43
Client-Server Model
Memory Server
File Server
Client Process
. . . . . .
Client Process
Kernel
Machine4
Machine3
Machine1
Machine2
Client
File Server
Process Server
. . . .
. . .
Kernel
Kernel
Kernel
Kernel
Network
Distributed System
44
Mechanism vs. Policy
  • Simple Kernel - modularity minimal privileged
    operation
  • Servers for files, memory, etc. - distribution
    user mode operation
  • good for distributed systems
  • Mechanism in kernel - how to do things..
  • Policy outside - decide what to do can be
    changed later..
  • Another solution Critical servers in kernel

45
  • Fig. 9-7. A Distributed System consisting of
    workstations on a LAN.
  • Fig 9-1. Advantages of distributed systems over
    centralized ones.

46
UNIX
  • UserInterface

47
UNIX Utility Programs
  • A few of the more common UNIX utility programs
    required by POSIX

48
UNIX Kernel
  • Approximate structure of generic UNIX kernel

49
Case Study 2 Windows 2000
  • Chapter 11

11.1 History of windows 2000 11.2 Programming
windows 2000 11.3 System structure 11.4
Processes and threads in windows 2000 11.5
Memory management 11.6 Input/output in windows
2000 11.7 The windows 2000 file system 11.8
Security in windows 2000 11.9 Caching in windows
2000
50
Windows NT
  • Some differences between Windows 98 and Windows NT

51
Windows 2000 (1)
  • Different versions of Windows 2000

52
Windows 2000 (2)
  • Comparison of some operating system sizes

53
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com