CH 1

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 60

OPERATING SYSTEMS

DESIGN AND IMPLEMENTATION


Third Edition
ANDREW S. TANENBAUM
ALBERT S. WOODHULL

Chapter 1
Introduction
Introduction
• Without software, computer is basically useless compact
mass of metal
• With software, computer can store, process and retrieve
information; play music and video; send emails ….etc
• 2 types of software
• Application programs: perform the actual work the user wants
• OS: control all the computer’s resources provide a base upon which the
application programs can be written
The Modern Computer System

Figure 1.1 A computer system consists of hardware,


system programs, and application programs.
What Is an Operating System?
• The operating system has two basic functions of the
operating system

• It is an extended machine or virtual machine


– Easier to program than the underlying hardware
(Controlling the hardware)
• It is a resource manager
– Shares resources in time and space
Operating System Generations
• Generation 1 (1945 – 55): Vacuum tubes and plugboards

• Generation 2 (1955 – 65): Transistors and batch systems

• Generation 3 (1965 – 80): ICs and multiprogramming

• Generation 4 (1980 – Present): Personal computers


First generation
• Mechanical relays  very slow (time in seconds)

• Use vacuum tubes VT


• Enormous (entire room)
• Slow than the cheapest computers available today
• Single group of people are the development team
• Computation in machine language (no assembly, no OS)
• Programmer sign up, enter in machine room, insert his plugboard in
computer and wait few hours (hoping that the VT don’t burn out)

• Use of punched cards


• Program written on card not in plugboard
Second generation
• Introduction of Transistors  reliable computers called
mainframe

• Separation between personnel (analyst, designer, tester,


programmer)

• Computers on AC rooms with professional operators

• Very expensive  used in some government agencies


and universities (price = multimillion $)
Second generation
• Programmer
– Write program on paper (Fortran language or Assembly language)
– Punch program on cards
– Brings cards to the input room
– Cards are handled by operators
– Programmer go to drink waiting the output
– Computer run the job
– Operator go to the printer, take the output, carry out the output room
– Programmer collect them later
Early Batch System (1)

Figure 1-2. An early batch system. (a) Programmers bring


cards to 1401. (b)1401 reads batch of jobs onto tape.
Early Batch System (2)

Figure 1-2. An early batch system. (c) Operator carries input


tape to 7094. (d) 7094 does computing.
Early Batch System (3)

Figure 1-2. An early batch system. (e) Operator carries output


tape to 1401. (f) 1401 prints output.
Second generation
• Problem: Cost very expensive and computer time was wasted
• Solution : Batch system
• Batch system
• Set of jobs
• Ancestor of today’s OS
• Example of batch
• FMS: Fortran Monitoring System
• IBSys: Ibm operating System
Early Batch System (4)

Figure 1-3. Structure of a typical FMS job.


Second generation
• $JOB cards, maximum run time in minutes, the account
number to be charged and the programmer name
• Fortran cards; load the Fortran from tape system compiler
• Fortan Program to be compiled
• Load Card: load the object program just compiled
• Run card; run the program with data following it
• end card; mark the end of the job
Third generation
• Word oriented  large scientific computer (7094)
• Character oriented  commercial computer (1401)
• Problem: Developing different product lines is very
expensive
• Solution: series of software-compatible machines which
differ only on price and performance
• Use of integrated circuit  cost  and the performance
• One OS for all machines (scientific and commercial)
Multiprogramming

Figure 1-4. A multiprogramming system with three jobs in memory.


Third generation
• Multiprogramming
• Avoid time wastage

• Full use of the CPU (busy 100)

• Memory partitions (each partition contain a job)

• Job protection (against snooping and mischief) in main memory using


special hardware

• Timesharing
• Local Area Network (LAN)
Fourth generation
• Use of microprocessor  price  and performance
• OS
• DOS (IBM)

• MSDOS

• Apple DOS

• MacDOS

• UNIX

• Distributed OS; multiprocessor (concurrency) but appear to user as uniprocessor


• Network OS; Internet where the machines are independent
Process management system
• Process are the key concepts
• Process are program in execution
• Process has
• @ space containing the executable program + data+ its stack

• List of memory location (from 0 to some max) which the process can read
and write

• Set of registers: program counter PC, stack pointer and other hardware
registers
Process management system
• In timesharing
• At the end of the quantum Stop process and run another
• Stopped process must restart exactly at the same state when it was stopped
 save all information about the process in process table (linked list)
• Core image = @ space of suspended process

• Process Management System calls deal with Process


creation and Process termination

• Using
• Shell or command interpreter
• Double click on icon in GUI
Process management system
• Process can create 1 or more child processes
• Child process can create child processes
  process tree

• Interprocess communication is communication and


synchronization between cooperative processes to
get some job
Processes

Figure 1-5. A process tree. Process A created two child processes, B and C.
Process B created three child processes, D, E, and F.
File Management system
• File management system  system calls (Create, remove,
Read, Write, Open and close a file)

• Directory = way of grouping files together

• File in directory is specified by giving its path name

• 2 path’s type
• Absolute path: from root

• Relative path: from current working directory


File Systems (1)

Figure 1-6. A file system for a university department.


File Management system
• File protection  11 bits binary protection code

• Bit SETGID: Set Group ID

• Bit SETUID: Set User ID

• 3 bits for user, 3 bits for group and 3 bits for everyone else

• Permission codes are


• R: read W: write
• X: execute (file) and search (directory) - : permission is absent

• Example rwxr-x--x
File Management system
• When file is opened, check the permission
• Yes: system return integer (file description)

• No: system return -1 (error code)

• Special file are provided to make I/O devices


• There is 2 types
• Block: used to model devices that consist of a collection of addressable block (example Hard
disk)

• Character: used to model devices that accept or output a character ( example printer)
File Systems (2)

Figure 1-7. (a) Before mounting, the files on drive 0 are not accessible. (b)
After mounting, they are part of the file hierarchy.

Mounting process is before your computer can use any kind of storage device (such
as a hard drive, CD-ROM, or network share)
you or your operating system must make it accessible through the computer's file
system. You can access only files on mounted media
File Management system
• Pipe is a pseudofile used to connect 2 processes

• The process A wants to send data to the process B

• Process A write data on the pipe

• Process B read data from the pipe


File Systems (3)

Figure 1-8. Two processes connected by a pipe.


System calls
• Interface between OS and its application programs

• If process is running a user program in user mode and


need a system service:

• it has to execute a system call instruction to transfer the control


to the OS

• OS figure out what the calling process wants by inspecting the


parameters.

• OS carries out the system call and return control the instruction
following the system call
System calls

• System call is like a special kind of procedure call

• System call enter in Kernel (system) mode

• Procedure call in user mode


System Calls (1)
Process Management

Figure 1-9. The MINIX system calls. fd is a file descriptor;


and n is a byte count.
The fork Call in the Shell
• Shell is command interpreter

• When a command is typed

– The shell create a new process

– Child process execute the user command by using execve

– Execve is a system call with 3 parameters

• File name to be execute

• Pointer to the argument array containing the command

• Pointer to the environment (like, home directory, terminal type ….etc.)


The fork Call in the Shell

Figure 1-10. A stripped-down shell. TRUE is assumed to be defined as 1.

A shell is a piece of software that provides an interface for users of an operating


system. Operating system shells generally fall into one of two categories:
command-line and graphical.
Processes
• Process have their memory divide up into 3 segments

– Text segment: contain the program code

– Data segment: contain the variables. Grows upward with a system


call brk (specifies the new @ where the date segment is to end).

– Stack segment: grows downward automatically as needed (without


system call)
Processes

Figure 1-11. Processes have three segments: text, data, and stack. In
this example, all three are in one address space, but separate
instruction and data space is also supported.
System Calls (2)
Signals is a mechanism to convey information to process that is
not necessary waiting for input

Figure 1-9. The MINIX system calls. fd is a file descriptor;


and n is a byte count.
System Calls (3)
File Management

Figure 1-9. The MINIX system calls. fd is a file descriptor;


and n is a byte count.
System Calls for File Management

Figure 1-12. The structure used to return information for the stat
and fstat system calls. In the actual code, symbolic names
are used for some of the types.
System Calls for File Management

Figure 1-13. A skeleton for setting up a two-process pipeline.


System Calls for File Management

Figure 1-13. A skeleton for setting up a two-process pipeline.


System Calls (4)

Dir. & File System Mgmt.

Figure 1-9. The MINIX system calls. fd is a file descriptor;


and n is a byte count.
System Calls for Directory Management

link(“/usr/jim/memo”,”/usr/ast/note”);

Figure 1-14. (a) Two directories before linking /usr/jim/memo to


ast’s directory. (b) The same directories after linking.
System Calls for Directory Management
mount : a system call that allows 2 file systems to be merged into one

mount(“/dev/cdrom0”,”/mnt”,0);

Figure 1-15. (a) File system before the mount.


(b) File system after the mount.
System Calls (5)
Protection

Figure 1-9. The MINIX system calls. fd is a file descriptor;


and n is a byte count.
System Calls (6)

Time Management

Figure 1-9. The MINIX system calls. fd is a file descriptor;


and n is a byte count.
Operating System Structure
• There is 5 different OS structures

• Monolithic Systems

• Layered System

• Virtual System

• Exokernels

• Client-Server System
Monolithic Systems
• There is a little structure.

• OS is a collection of procedures, each which can call any of the


other.

• System calls are requested by putting the parameters in well


defined places (stack or registers).

• 2 type of mode

– Kernel mode: for OS, in which all instructions are allowed

– User mode: for user, in which I/O and certain other instructions are not
allowed
Monolithic System
•The kernel is
• The central component of most computer operating systems;
• A bridge between applications and the actual data processing
done at the hardware level
Monolithic System

Figure 1-16. The 11 steps in making the system call


read(fd, buffer, nbytes).
Monolithic Systems
• 11 steps for read system call
• Step 1-3 : Push the parameters onto the stack

• Step 4 : Call to the library procedure

• Step 5 : Puts the system call number in a register

• Step 6 : Switch the user mode to kernel mode

• Step 7 : Dispatch to the correct handler

• Step 8 : Run the handler

• Step 9 : Return to user space library procedure

• Step 10 : Return to the user program

• Step 11 : Clean up the stack


Basic Structure for OS
1. A main program that invokes the
requested service procedure

2. A set of service procedures that carry out


the system calls

3. A set of utility procedures that help the


service procedures
Monolithic System

Figure 1-17. A simple structuring model for a monolithic system.


Layered Systems
• Generalization of the monolithic system
• OS is organize as a hierarchy of layers each one structured upon
the one below it
• OS had 6 layers

Figure 1-18. Structure of the operating system.


Virtual Machines
• Runs on bare hardware

• Multiprogramming which provides several virtual


machines to the next level

• The virtual machines are exact copies of the bare


hardware

• Different virtual machines can run different OS

• some virtual machines run a single-user, interactive


system called Conventional Monitor System CMS for
timesharing users
Virtual Machines

Figure 1-19. The structure of VM/370 with CMS (Conversational Monitor


System)
Exokernels
• Each user has a clone of the actual computer with a
subset of the resources

• example VM1 get disk block from 0 to 1023 and VM2 get
blocks from 1024 to 2047 and so on

• Exokernel is a program running in the kernel mode at the


bottom layer

• Its job is to allocate resources to VM and check attempts to


use them to make sure no machine is trying to use
somebody else’s resources
Client-Server systems
• Approach is to implement most OS functions in user
processes.

• No system calls.

• To request a service, a user process (client) sends the


request to server which does the work and sends back the
answer to the client.

• The kernel’s task is to handle the communication between


the clients and servers.
Client-Server Model (1)

Figure 1-20. The client-server model.


Client-Server Model (2)

Figure 1-21. The client-server model in a distributed system.

You might also like