Professional Documents
Culture Documents
2. Introduction to O.S.
2011/2012
Luis Moura e Silva Email: luis@dei.uc.pt Departamento de Eng. Informtica Universidade de Coimbra
Disclaimer
This slides and notes are heavily based on the companion material of [Silberschatz05].The original material can be found at:
http://codex.cs.yale.edu/avi/os-book/os7/slide-dir/index.html
In some cases, material from [Stallings04] may also be used. The original material can be found at:
http://williamstallings.com/OS/OS5e.html
scheduling allocation improving utilization minimizing overhead improving throughput/good put enforcement of boundaries
Virtual Time and Real Time Operating Systems Examples of OS with Virtual Time:
User Mode
Kernel Mode
I/O devices and the CPU can execute concurrently Each device controller is in charge of a particular device Each device controller has a local buffer CPU moves data from/to main memory to/from local buffers I/O is from the device to local buffer of controller Device controller informs CPU that it has finished its operation by causing an interrupt
10
Interrupt Timeline
11
12
13
Used for high-speed I/O devices able to transmit information at close to memory speeds Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention Implies the capability of arbitrating the system bus Only one interrupt is generated per block, rather than the one interrupt per byte
14
DMA (2)
15
Protection
Dual Mode of Operation User Mode and Kernel Mode In User Mode only common instructions can be performed (e.g. arithmetic and logic). In Kernel Mode can do anything. A mode bit contains the current mode of operation RTI: Return from interruption Kernel mode assumed on traps and on interrupts I/O Protection All I/O Instructions are privileged. For doing I/O a trap into the operating system must be generated. Memory Protection Each program can only access its memory CPU Protection The CPU must remain in control of the Operating System, even if the applications dont want to let go.
16
17
System calls
Traps
Operating System
Interrupts
18
19
It allows you to see what system calls are made and with what parameters!
20
strace in Action!
21
Storage Hierarchy
22
Storage Hierarchy
23
Memory Protection
Segmentation is based on having a base pointer and a limit for each process running
Any access made outside of its space generates a trap and normally leads to the process being killed
Virtual Memory is based on having a table that translates virtual addresses into real ones
Normally, there is such a table for each process Each process sees all the address space An access made to an non existing page generates a trap and normally leads to the process being killed
24
Segmentation
25
Virtual Memory
4Gb
1000 0
Address Space of Process A
1000 0
Address Space of Process B
256Mb
Physical Memory
(simplified)
26
Multiprogramming
Multiprogramming: maintaining several jobs in memory, active at the same time, so that when the current program can no longer run (for example because its blocked waiting for I/O), another is available to run Optimizes resource utilization: CPU and I/O
CPU
Multitasking
Multitasking is an extension of multiprogramming in which the execution of the active programs is time-sliced:
Each program runs for a short period of time, then another is run. When a program is running and is forcibly replaced by another, typically with a higher priority, it is said to have been preempted, thus the term Preemptive Operating Systems
28
Multitasking
Every few milliseconds (e.g. 100ms), the interrupt causes a task (or process) switch
User Level
total = 0; for (int i=0; i<20000; i++) total = total + i; printf(total=%d\n, total);
(...)
Kernel Level
Interrupt Handler
29
Nowadays
Preemptive multitasking operating systems using virtual memory Each process thinks it has the whole computer for itself Virtual Machine
30
Moves as much as possible 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 SLOW: Performance overhead of user space to kernel space communication
31
Detriments:
Consists of everything below the system-call interface and above the physical hardware Provides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level Benefits:
FAST! Less reliable (more code is running in kernel mode) Less secure No so easy to port to new architectures ( it depends)
32
Detriments:
Uses object-oriented approach Each core component is separate Each talks to the others over known interfaces Each is loadable as needed within the kernel
Benefits
Its easier to extend the operating system Allows to isolate functionality in well defined software entities, making the OS more maintainable and reliability
33
Virtual Machines
Facet A:
Abstract Machine that runs bytecode (e.g. Java, MS.NET) Good for portability, allowing running the same unmodified application in different physical architectures
Facet B:
Software that allows different operating systems to be run in parallel giving them the illusion of having a whole machine (e.g. VMWARE, XEN, Virtuozzo, ) Some Virtual Machines run on top of the hardware: IBM z/VM Others run on top of the host OS: XEN, VMWARE, etc Allows for server consolidation, software testing, software fault tolerance, etc.
34
VMWARE Architecture
35
Reference
Chapter 1: Introduction
All chapter 2! 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10
36