NETW 3005 - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

NETW 3005

Description:

NETW 3005 Types of scheduler Long-term scheduler (batch systems): decides which jobs loaded onto the disk should be moved to main memory. Short-term scheduler (a.k.a ... – PowerPoint PPT presentation

Number of Views:63
Avg rating:3.0/5.0
Slides: 43
Provided by: Compute381
Category:

less

Transcript and Presenter's Notes

Title: NETW 3005


1
NETW 3005
System Structure and Processes
2
Reading
  • For this lecture, you should have read Chapter 2
    (Sections 1-9).

3
Last lecture
  • History and types of operating systems
  • batch systems, multiprogramming systems, time
    sharing systems, etc.
  • Operating system tasks
  • process management, storage management, I/O
    device management, user interface.

4
This lecture
  • Hierarchical Structure in Operating Systems
  • System calls and interrupts
  • Representing processes in Operating Systems
  • Overview of process scheduling.

5
Hierarchical structure in OS
  • An operating system, like any complex computer
    system, must be carefully designed.
  • One central requirement is modularity.
  • Distinction between system programs and
    application programs.

6
(No Transcript)
7
Application programs
  • Ones that ordinary users interact with
  • Word-processors
  • Database packages
  • Web browsers
  • Compilers, editors, IDEs, etc
  • . . .

8
System programs
  • Provide a general-purpose lower-level function.
    System functions include
  • file manipulation create, delete, copy etc.
  • status info date, available memory.
  • program loading and execution.
  • communication between processes.
  • Command interpreters (a.k.a. shell programs). The
    set of system programs de?ne the user interface.

9
Other system functions
  • Not strictly part of the OS, but often packaged
    with it.
  • Programs to modify files (text editors, search,
    transform).
  • Compilers, assemblers and interpreters.

The set of system programs defines the user
interface.
10
Degrees of modularity
  • Different operating systems enforce different
    degrees of modularity.
  • Ideally you want to oblige all system and
    application programs to talk to the hardware via
    the kernel.

11
MS-DOS
Application programs
System programs
Kernel operations
Device drivers
Terminal drivers
Memory manager
COSC 243 (Operating Systems)
11
12
Talking to the kernel system calls
13
System calls
  • Written in the same language as kernel (typically
    C).
  • Available to Assembler and (at least) some HLLs
    C, Perl, etc.
  • The set of system calls is termed the programmer
    interface to the system.

14
A simple system program  copy
  • cp file1 file2
  • Open file1 Create file2.
  • Loop Read from file1 Write to file2.
  • Close file1 Close file2.

15
Types of system call (1)
  • Process control
  • create, terminate, suspend, resume, abort.
  • File manipulation
  • open, close, read, write
  • Device manipulation
  • request, release, read, write.

16
Types of system call (2)
  • Housekeeping
  • get/set time or date
  • get/set attributes (process, device, file)
  • Communications
  • set up link,
  • send/receive message

17
InterruptsHow system calls are implemented
  • CPU responds to interrupts no matter what else it
    happens to be doing.
  • An interrupt transfers control to an appropriate
    module in the kernel.
  • A system call transfers control to the kernel by
    generating an interrupt (sometimes called a trap
    in this context).

18
Responding to an interrupt
  • Effectively a Jump to Subroutine
  • current instruction address (PC) is saved
  • control transferred to fixed address, depending
    on the interrupt.
  • The interrupt vector is an array of locations
    that hold the addresses of these routines,
    usually held in low memory.

19
Implementation issues
  • How do we guarantee that the interrupt-handing
    routine wont affect the interrupted process?
  • What happens if an interrupt occurs while an
    interrupt-handling routine is executing?

20
Virtual machines
  • System calls allow the OS to hide the low-level
    hardware from application programs.
  • In a virtual machine these system calls are
    executed by a program which emulates the
    hardware.
  • This hardware may, or may not be the same as the
    actual hardware.

21
processes
kernel
hardware
22
Benefits of virtual machines
  • Protection users arent even aware there are
    other users.
  • Good for operating systems R D. (No down-times
    just give a system programmer her own virtual
    machine.)
  • A way of solving system-compatibility problems.

23
Problems with virtual machines
  • Speed virtual machines are slower.
  • Implementation is very difficult, e.g. resource
    allocation (particularly disc).

24
Java
  • Compiled Java code is called byte-code.
  • It is designed to run on the Java Virtual Machine
    (JVM).
  • Think about the command-line process of compiling
    and running a Java program as opposed to
    compiling and running a C program.

25
Processes
  • Recall a process is not just a program it is a
    dynamic entity.
  • A given program (e.g. emacs) could be executing
    many times on a given machine the machine must
    represent each execution as a separate process.

26
Components of a process (1)
  • Code section the program code itself
  • Data section any global variables used by the
    program
  • Process stack any local variables currently
    being used (subroutine parameters, return
    addresses, etc.)
  • Program counter a pointer to some place in the
    program code.

27
Components of a process (2)
  • Contents of CPU registers.
  • Memory management information.
  • Accounting information who owns the process, how
    long its been running, how much CPU time its
    used so far, etc.

28
Process state
  • The operating system keeps track of the state of
    each process.
  • A process can be in any of the following states
  • new
  • running
  • waiting/blocked
  • ready
  • terminated

29
An Example from MacOS X
  • oucs1046 chandley ps ax

30
Macos X processes (1)
PID TTY TIME CMD 1 ?? 126.15
/sbin/launchd 10 ?? 003.03 /usr/libexec/kextd 1
1 ?? 106.37 /usr/sbin/DirectoryService 12 ??
027.57 /usr/sbin/notifyd 13 ?? 1511.87
/usr/sbin/syslogd 14 ?? 208.74
/usr/sbin/configd 15 ?? 018.55
/usr/sbin/distnoted 16 ?? 2523.28
/usr/sbin/mDNSResponder launchd 20 ?? 003.56
/usr/sbin/securityd -i
31
Macos X processes (2)
24 ?? 124.42 /usr/sbin/ntpd -n -g -p 25 ??
002.00 /usr/sbin/cron 26 ?? 1758.14
/usr/sbin/update 27 ?? 000.01
/sbin/SystemStarter 31 ?? 000.03
/System/Library/CoreServices/
32
Macos X processes (3)
  • Produced 75 different processes.
  • Several distinct classes
  • Daemons security, cron, update, etc.
  • Core Services Dock, Finder, etc.
  • Network and communications.
  • Application programs Preview, Power-Point,
    Word, Adobe Acrobat, etc.

33
Scheduling an overview
Disk
Job2, Job2, Job3, Job4,
34
Types of scheduler
  • Long-term scheduler (batch systems) decides
    which jobs loaded onto the disk should be moved
    to main memory.
  • Short-term scheduler (a.k.a. CPU scheduler)
    chooses how to allocate the CPU between the
    processes which are ready to execute.

35
Scheduling queues
  • The relationships between processes are
    represented by the O/S as queues.
  • Job queue all the processes in the system
    (including those on disk).
  • Ready queue all the processes which are ready to
    execute.
  • Device queue all the processes waiting to use a
    particular device. (One queue per device.)

36
The Flow of Processes in an OS
ready queue
I/O request
fork
interrupt mechanism
37
Process creation
  • A process is created (spawned) by another
    process we talk of parent and child processes.
  • When you launch an application, the terminal
    process spawns the application process.
  • Processes are able to call other processes,
    just as a program can call functions.

38
Differences
  • A child process can (and often does) run
    concurrently with its parent.
  • A child process neednt be constrained to use the
    resources of its parent (although it may be, and
    often is).

39
A process tree (1)
root
40
A process tree (2)
  • Note that users are treated as processes by the
    operating system.
  • How does that work?
  • Answer users are really represented to the
    system as shell processes.
  • An important notion the root user.

41
Homework
  • The Unix command ps displays information about
    processes on the system. Read the man page for ps
    (i.e. do man ps), and try out some of the
    options.

42
Next Lecture
Threads and Data Sharing Chapter 4 (Sections 1-4)
Write a Comment
User Comments (0)
About PowerShow.com