Download Common System Components - Operating Systems, Distributed Computation - Lecture Slides and more Slides Operating Systems in PDF only on Docsity! Common System Components • Process Management • Main Memory Management • File Management • I/O System Management • Secondary Management • Networking • Protection System • Command-Interpreter System Docsity.com Process Management • A process – is a program in execution. – needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task. • The OS’s responsibility in process management: – Process creation, deletion, suspension and resumption. – Provision of mechanisms for: • process synchronization • process communication Docsity.com File Management • A file is a collection of related information. • Files usually represent programs (both source and object forms) and data. • The OS’s responsibility with file management: – File creation and deletion. – Directory creation and deletion. – Support of primitives for manipulating files and directories. – Mapping files onto secondary storage. – File backup on stable (nonvolatile) storage media. Docsity.com I/O System Management • The I/O system consists of: – A buffer-caching system – A general device-driver interface – Drivers for specific hardware devices Docsity.com Secondary-Storage Management • Main memory is volatile and too small. OS must provide secondary storage to back up main memory. • Most modern computer systems use disks as the principle on-line storage medium, for both programs and data. • The OS’s responsibilty with disk management: – Free space management – Storage allocation – Disk scheduling Docsity.com Protection System • Protection refers to a mechanism for controlling access by programs, processes, or users to both system and user resources. • The protection mechanism must: – distinguish between authorized and unauthorized usage. – specify the controls to be imposed. – provide a means of enforcement. Note: This goes beyond kernel/user-mode protection Docsity.com Command-Interpreter System • Many commands are given to the operating system by control statements which deal with: – process creation and management – I/O handling – secondary-storage management – main-memory management – file-system access – protection – networking Docsity.com Command-Interpreter System • The program that reads and interprets control statements is called variously: – command-line interpreter (CLI) – shell (in UNIX) • Its function is to get and execute the next command statement. Docsity.com Additional OS Functions • Resource allocation – allocating resources to multiple users or multiple jobs running at the same time. • Accounting – for account billing or for accumulating usage statistics. • Protection – ensuring that all access to system resources is controlled. Docsity.com SYSTEM CALLS Docsity.com System Calls • Provide the interface between a running program and the OS. – Generally available as assembly-language instructions. – Languages defined to replace assembly language for systems programming allow system calls to be made directly (e.g., C, C++) Docsity.com System Call Memory Map
Address
OxFFFFFFFF r
User space
Kernel space
(Operating system)
B he
or
Return to caller
Trap to the kernel
5| Put code for read in register
Increment SP 11
r Call read
3} Push fd
2| Push &buffer
1] Push nbytes
a 8 | Sys call
pra handler
;
Library
procedure
read
User program
calling read
Docsity.com
Types of System Calls • Process control • File management • Device management • Information maintenance • Communications Docsity.com Types of System Calls • Process control Call Description pid=fork() Create a child process identical to parent pid=waitpid(pid, &statloc, options) Wait for child to terminate s=execve(name, argv, environp) Replace a process’ core image exit(status) Terminate proc execution & return status Docsity.com UNIX vs Win System Calls • UNIX – One-to-one relationship between system calls (e.g., read) and library procedures (e.g., read) to invoke system calls. – i.e., for each syscall roughly one library procedure that is called to execute it. • Windows – radically different. – library calls and syscalls are highly decoupled. – Win32 API defined for programmers to use to get OS services. – Supported on all versions of Windows since Win95. – Difficult to distinguish kernel syscall and user(-space) library calls Docsity.com UNIX vs Win System Calls
UNIX
Win32 Description
fork CreateProcess Create a new process
waitpid | WaitForSingleObject| Can wait for a process to exit
execve | (none) CreateProcess = fork + execve
exit ExitProcess Terminate execution
open CreateFile Create a file or open an existing file
close CloseHandle Close afile |
read ReadFile Read data from a file -
write WriteFile _ Write data to a file -
lseek SetFilePointer Move the file pointer
stat GetFileAttributesEx | Get various file attributes -
mkdir CreateDirectory Create a new directory |
tmdir | RemoveDirectory Remove an empty directory
link (none) Win32 does not support links -
unlink | DeleteFile _ Destroy an existing file :
mount | (none) Win32 does not support mount —
umount | (none) Win32 does not support mount
chdir SetCurrentDirectory | Change the current working directory
hmod | (none) Win32 does not support security (although NT does)
ll (none) Win32 does not support signals
time GetLocalTime Get the current time
Docsity.com
MS-DOS Execution
free memory
free memory
command
interpreter
process
kernel
command
interpreter
(a)
kernel
(b)
At System Start-up
Running a Program
Docsity.com
System Programs • Provide a convenient environment for program development and execution. The can be divided into: – File manipulation – Status information – File modification – Programming language support – Program loading and execution – Communications – Application programs • Most users’ view of the operation system is defined by system programs, not the actual system calls. Docsity.com MS-DOS System Structure • MS-DOS – written to provide the most functionality in the least space – not divided into modules – Although MS-DOS has some structure, its interfaces and levels of functionality are not well- separated Docsity.com MS-DOS Layer Structure
application program
resident system program
MS-DOS device drivers
ROM BIOS device drivers
Docsity.com
Layered Approach • the OS is divided into a number of layers (levels), each built on top of lower layers. – the bottom layer (layer 0) is the hardware – the highest (layer N) is the user interface. • With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers. Docsity.com An Operating System Layer
> layer M
new
operations
>
—+>
hidden . layer M— 1
operations
—_
wo >
existing
operations
>
>) Docsity.com
Microkernel System Structure • Moves as much from the kernel into “user” space. • Communication takes place between user modules using message passing. • Benefits: – easier to extend a microkernel – easier to port the operating system to new architectures – more reliable (less code is running in kernel mode) – more secure Docsity.com Virtual Machines (Cont.) • The resources of the physical computer are shared to create the virtual machines. – CPU scheduling can create the appearance that users have their own processor. – Spooling and a file system can provide virtual card readers and virtual line printers. – A normal user time-sharing terminal serves as the virtual machine operator’s console. Docsity.com System Models
processes
processes
processes processes
ea P oerface kernel kernel kernel
VM1 VM2 VM3
kernel
virtual machine
implementation
hardware
hardware
irtual Machine Virtual Machipresity.com
VM Advantages/Disadvantages • provides complete protection of system resources since each VM is isolated from all other VMs. isolation permits no direct sharing of resources. • perfect vehicle for OS R&D. System development is done on the VM, instead of on a physical machine does not disrupt normal system operation. Docsity.com Java Virtual Machine
java .class files
{
class loader
'
verifier
'
java interpreter
[4
host system
Docsity.com
System Design Goals • User goals – OS should be convenient to use, easy to learn, reliable, safe, and fast. • System goals – OS should be easy to design, implement, and maintain, as well as flexible, reliable, secure, error- free, and efficient. Docsity.com Mechanisms and Policies • Mechanisms determine how to do something, policies decide what will be done. • The separation of policy from mechanism is a very important principle – allows maximum flexibility if policy decisions are to be changed later. Docsity.com