Sysenv
Sysenv
Fred Kuhns
[email protected]
Applied Research Laboratory,
Department of Computer Science and Engineering,
Washington University in St. Louis
Washington
WASHINGTON UNIVERSITY IN ST LOUIS
Model and Core Abstractions
• Basic model
– computer used to access, transform and store information.
• OS provides abstractions to facilitate the information
processing task and its conceptualization.
• Common abstractions in modern systems:
– Process – basic unit of computation
– File – basic unit of information storage
• Less common abstractions (in an OS): Objects
– Objects – basic unit of computation
– performs computation on internal data in response to messages,
may also send messages to other objects.
• Using resources with the process model
– a process must request resources from the OS
– a process must suspend operation until resource is allocated
Fred Kuhns (01/17/09) CS422 – Operating Systems Concepts 2
Processes and Resources
An application consists of one or more processes, a set of resources and state
Resources
Processes
File F0
Process P0
File F1
Process P1
... ...
File FM
Process PN
memory Ri
...
CPU
display Rj
Operating System
other
CPU DRAM DISKS NET other
other
Fred Kuhns (01/17/09) CS422 – Operating Systems Concepts 3
Traditional UNIX Model
execution
environment application
libraries
user
kernel System call interface
Other IPC
Process
Resources control scheduler
File subsystem
subsystem
memory
hardware
close (ifd);
close (ofd);
exit(0);
}
Fred Kuhns (01/17/09) CS422 – Operating Systems Concepts 6
Computations, Processes and Threads
• Common model: A computation is the sequential execution of a set of
instructions implementing some algorithm and applied to a specific
data set.
• A program results from the encoding of an algorithm using a
programming language (like C or C++).
– program source is compiled to produce instructions native to the target
platform, i.e. the binary.
• A programmer requests resources from the operating using the
exported OS interface, aka system call interface.
• Classical definition of a process is a program in execution and
embodies all resources and state of a running program (CPU,
memory, files,...)
• Modern systems separate program execution context from other
process resources. A process may have multiple execution contexts
for a given process. Thread is an execution context.
Resource R0
Code Data
Resource R1
Context
Resource RN
• Process consists of
– object code (program) to be executed
– data which the process works on
– Required resources
– Execution status, used by the OS to manage process
Process P2
Resource R0
Code Data
Resource R1
Context
Resource RN
Process P3
Resource R0
Code Data
Resource R1
Context
Resource RN
Resource R0
Code Data
T1 T1 Resource R1
... context
context Resource RN
• Process: encompasses
– set of threads (computational entities)
– collection of resources
• Thread: Dynamic object representing an execution path and
computational state.
– threads have their own computational state: PC, stack, user registers
and private data
– Remaining resources are shared amongst threads in a process
Fred Kuhns (01/17/09) CS422 – Operating Systems Concepts 10
UNIX Process Model
Resource 1
Resource N
Text Data
(code) Stack
File 1
Status
File 2
Data
0x7fffffff Kernel Text
stack
Data
0x00000000 Text (shared)
Fred Kuhns (01/17/09) CS422 – Operating Systems Concepts 12
UNIX Process Operations
• Well defined hierarchy: one parent and zero or more
child processes. The init process is at the root of this
tree
• Create new process (i.e. child) using fork or vfork
– create new address space
– copies text, data and stack
– child has access to all parent’s open files
• Different programs may be run during the life of a
process by calling exec
• Processes terminate by calling exit
• Parent may wait for child to terminate, and colledt
exit status, by calling wait
• Issues in OS design
– Performance – should be low overhead
– Exclusive use of resources
• protection and security – sharing, authorizing, authenticating
– correctness – does what it is supposed to do
– maintainability – universal goal
– commercial – they are used by people and organizations
– standards and open systems – conforming to standards
• Common implementation mechanisms
– Protection and processor modes
– Trusted control program – kernel
– Method for processes to request services of the OS – system
calls
subsystem
char block Memory
Device drivers
hardware
Fred Kuhns (01/17/09) CS422 – Operating Systems Concepts 18
Policy and Mechanism
• A recurring theme in OS design is ensuring exclusive
use of system resources (real and abstract)
• Administrators and developers define policies to
define resource sharing and isolation
• Mechanisms implement these policies
• Common mechanisms:
– hardware enforced processor modes to control execution of
privileged instructions (such as for I/O or memory)
– Core OS modules are trusted and have access to protected
operations and all resources. This kernel of the OS is
responsible for enforcing policies.
– Well defined and protected mechanism for requesting services
of the OS. There are two approaches: system calls or message
passing.
Privileged
mode
user kernel
context
Application System calls
process
(user code) Exceptions
system X Interrupts,
kernel
space not allowed System tasks