Académique Documents
Professionnel Documents
Culture Documents
Foundations
THE PROCESS AND THE
KERNEL
Course Description
The Goals for this course
Understand UNIX
Understand Operating Systems
Prerequisites:
COSC 2P13 : Introduction to Operating
Systems
COSC 2P91 : Procedural Programming
Course Description
An intensive study of computer operating
system design
Multiprogramming
Time-sharing
Real-time processing
Job and task control
Synchronization of concurrent processes and
processors
Resource scheduling
Protection
Management of hierarchical storage.
How to study this course
Solaris ULTRIX
4.4BSD
HP-UX
SVR4
SCO UNIX 4.3BSD
AIX SunOS
SVR3
4.2BSD
XENIX
SVR2
4BSD
3BSD
UNIX
V1
.
.
Summary of
UNIX History
.
V6
Xenix BSD
V7
PWB
2BSD
.
PWB2 32V .
3BSD
.
2.9BSD
SIII V8
Xenix2 2.10BSD
4BSD
SYSV 2.11BSD
V10 4.2BSD
4.3BSD
SCO V.2 Plan9
Ultrix 4.4BSD
V.3 AIX SUNOS
V.3.2 Mach
LINUX
Flexibility
Advantages: -
open software process, -
well designed, small and simple kernel,
- text files in
system databases, - simple,
uniform interface to I/O devices,
- portability (written in
C)
Assessment of UNIX
Disadvantages:
- expansion of the more and more complex I/O
library, - unfriendly
user interface, - building
block approach to tools, but not to the kernel,
- too many
versions and standards, -
monolithic, unmodular and more and more
complex kernel.
UNIX Architecture
Application Programs
Kernel
Compiler
Hardware
User
Interface
cp src dest
head –20 file
ls *.c
sort <in >out
sort <in >temp;head –30<temp;rm temp
sort <in | head –30
grep ter *.t | sort | head –20 | tail –5 >foo
sort <x | head &
Process
In UNIX
Process is an instance of a running program.
Lifetime: fork/vfork->exec->exit
Well-defined hierarchy: parent,child,init,
init process: the top process
swapper & pagedeamon
Orphans: the parent process is terminated.
Process Creation
I/Ofailure
Invalid instruction
happens when try to execute data
Privilegedinstruction
Data misuse
Operating system intervention
such as when deadlock occurs
Parent terminates so child processes
terminate
Parent request
Process States
The Running state
The process that gets executed (single CPU)
The Ready state
any process that is ready to be executed
Time-out
Event Event
Occurs Wait
Blocked
Single Blocked Queue
Ready Queue
Dispatch Release
Admit
Processor
Time-out
Event Wait
Event
Occurs
Blocked Queue
Multiple Blocked Queues
Ready Queue
Dispatch Release
Admit
Processor
Time-out
Event 1 Queue
Event 2 Queue
Suspended Processes
Admit Suspend
Admit
Activate Dispatch
Ready, Ready Running Exit
suspend
Suspend Time out
Event Event
Event
Occurs Wait
Occurs
Activate
Blocked, Blocked
suspend
Processor State
Information
Contents of processor registers
User-visible registers
Control and status registers
Stack pointers
Program status word (PSW)
contains status information
Process Control
Information
Additional information needed by the operating
system to control and coordinate the various
active processes
scheduling and state information
data structuring
interprocess communication
process privileges
memory management
resource ownership and utilization
Process Creation
in 4.3BSD UNIX
parent’s
proc
Pointer to the
younger sibling Pointer to the oldest child
Typical Functions of an
Operating-System Kernel
Process Management
Process creation and termination
Process scheduling and dispatching
Process switching
Process synchronization and support for
inter-process communication
Management of process control blocks
Memory Management
Allocation of address space to processes
Swapping
Page and segment management
Typical Functions of an
Operating-System
I/O Management
Kernel
Buffer management
Allocation of I/O channels and devices to processes
Support Functions
Interrupt handling
Accounting
Monitoring
Operating System
Control Structures
An OS maintains the following
tables for managing processes
and resources:
Memory tables
I/O tables
File tables
Process tables
Memory Tables
Existence of files
Location on secondary memory
Current Status
Attributes
Sometimes this information is maintained by a
file-management system
Process Table
BACK
Mode,Space & Context
if ((result = fork()==0){
/* child code*/
… …
if (execve(“new program”),…)<0)
perror(“execve failed!”);
} else if (result<0) {
perror(“fork”);/*fork failed*/
}
/*parent continures here*/
Shell creating a
process