slides 2 operating systems
TRANSCRIPT
-
8/3/2019 Slides 2 Operating Systems
1/36
OperatingSystems
Luis Moura e SilvaEmail: [email protected] de Eng. InformticaUniversidade de Coimbra
2011/2012
2. Introduction to O.S.
-
8/3/2019 Slides 2 Operating Systems
2/36
2
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. Theoriginal material can be found at:
http://williamstallings.com/OS/OS5e.html
The respective copyrights belong to their owners.
-
8/3/2019 Slides 2 Operating Systems
3/36
3
Whats an Operating System?
-
8/3/2019 Slides 2 Operating Systems
4/36
4
What Operating Systems Do:
Sharing resources among applications
scheduling allocation
Making efficient use of limited resources improving utilization minimizing overhead improving throughput/good put
Protecting applications from each other enforcement of boundaries
-
8/3/2019 Slides 2 Operating Systems
5/36
5
Classification of Operating Sytems
Virtual Time and Real Time Operating Systems
Examples of OS with Virtual Time: Windows, Unix, Linux, Mac OS X, Novell,
Examples of Real-Time Operating SystemsVxWorks, VRTX, pSOS, LynxOS,
Embedded Operating Systems Symbian, WindowCE, PalmOS, iPhone OS, Android,
Open/Closed Operating Systems: Proprietary Open systems Open-source systems (GPL license)
-
8/3/2019 Slides 2 Operating Systems
6/36
6
Market Share Desktop OS: July 2011
-
8/3/2019 Slides 2 Operating Systems
7/36
7
Share Mobile Operating Systems: Q1 2011
-
8/3/2019 Slides 2 Operating Systems
8/36
8
Simple Organization of an Operating System
KERNEL
System Libraries
Applications
Protection
Barrier
-
8/3/2019 Slides 2 Operating Systems
9/36
9
Two Modes of Operation (to assure security)
User Mode
Kernel Mode
UNIX Operating System Structure
-
8/3/2019 Slides 2 Operating Systems
10/36
10
Input/Output versus CPU Usage
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 itsoperation by causing an interrupt
-
8/3/2019 Slides 2 Operating Systems
11/36
11
Interrupt Timeline
-
8/3/2019 Slides 2 Operating Systems
12/36
12
Different Types of I/O
-
8/3/2019 Slides 2 Operating Systems
13/36
13
Device Status Table
-
8/3/2019 Slides 2 Operating Systems
14/36
14
Direct Memory Access (DMA)
Used for high-speed I/O devices able to transmitinformation at close to memory speeds
Device controller transfers blocks of data from bufferstorage directly to main memorywithout CPUintervention
Implies the capability ofarbitrating the system bus
Only one interrupt is generated per block, rather than theone interrupt per byte
-
8/3/2019 Slides 2 Operating Systems
15/36
15
DMA (2)
-
8/3/2019 Slides 2 Operating Systems
16/36
16
Protection
Dual Mode of OperationUser 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 ProtectionAll 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.
-
8/3/2019 Slides 2 Operating Systems
17/36
17
Dual Mode of Operation
-
8/3/2019 Slides 2 Operating Systems
18/36
18
System Calls, Traps and Interrupts
OperatingSystem
Interrupts
TrapsSystem calls
-
8/3/2019 Slides 2 Operating Systems
19/36
19
Structure of a System Call
-
8/3/2019 Slides 2 Operating Systems
20/36
20
Example with a Hello World Application!
The strace program is very useful: It allows you to see what system calls are made and with what
parameters!
#include
int main() {printf(Hello World\n);return0;
}
-
8/3/2019 Slides 2 Operating Systems
21/36
21
strace in Action!
-
8/3/2019 Slides 2 Operating Systems
22/36
22
Storage Hierarchy
Caches, Buffers and a Storage Hierarchy are Essential
-
8/3/2019 Slides 2 Operating Systems
23/36
23
Storage Hierarchy
A great part of this hierarchy is controlled by theOperating System Cache Management Policies Buffer Management Policies Memory Management Policies
Principles of Locality:
- Temporal Locality
- Spatial Locality
-
8/3/2019 Slides 2 Operating Systems
24/36
24
Memory Protection
Each program must only be able to access its ownmemory Segmentation Virtual Memory
Segmentation is based on having a base pointer and alimit for each process runningAny 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 translatesvirtual addresses into real ones
Normally, there is such a table for each process Each process sees all the address spaceAn access made to an non existing page generates a trap and
normally leads to the process being killed
-
8/3/2019 Slides 2 Operating Systems
25/36
25
Segmentation
-
8/3/2019 Slides 2 Operating Systems
26/36
26
Virtual Memory
0 0
4Gb 4Gb
Address Space
of Process AAddress Space
of Process B
1000 1000
Physical Memory0
256Mb
5000
Address Translation
Table
Disk
(simplified)
-
8/3/2019 Slides 2 Operating Systems
27/36
27
Multiprogramming
Multiprogramming:maintaining several jobs inmemory, active at the same time, so that when thecurrent program can no longer run (for example becauseits blocked waiting for I/O), another is available to run
Optimizes resource utilization: CPU and I/O
CPU
Time Multiplexed CPU
E.g. Windows 95/98!
-
8/3/2019 Slides 2 Operating Systems
28/36
28
Multitasking
Multitasking is an extension of multiprogramming inwhich 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
-
8/3/2019 Slides 2 Operating Systems
29/36
29
Multitasking
For implementing multitasking, a non-maskableinterrupt must connected to a hardware timer Every few milliseconds (e.g. 100ms), the interrupt causes a
task (or process) switch
total = 0;
for (int i=0; i
-
8/3/2019 Slides 2 Operating Systems
30/36
30
Nowadays
Windows XP, Linux 2.6.xx: Preemptive multitasking operating systems using virtual
memory
Each process thinks it has the whole computer for itself Virtual Machine
-
8/3/2019 Slides 2 Operating Systems
31/36
31
Operating System Architecture and Structures
Currently, there are two dominant architectures
Microkernel: 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
Detriments: SLOW: Performance overhead of user space to kernel space
communication
-
8/3/2019 Slides 2 Operating Systems
32/36
32
Operating System Architecture and Structures
Currently, there are two dominant architectures
Monolithic: 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 functionsfor one level
Benefits: FAST!
Detriments: Less reliable (more code is running in kernel mode) Less secure No so easy to port to new architectures ( it depends)
-
8/3/2019 Slides 2 Operating Systems
33/36
33
Operating System Architecture and Structures
Most modern operating systems implementkernel modules 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 systemAllows to isolate functionality in well defined software entities,
making the OS more maintainable and reliability
-
8/3/2019 Slides 2 Operating Systems
34/36
34
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, etcAllows for server consolidation, software testing, software fault
tolerance, etc.
-
8/3/2019 Slides 2 Operating Systems
35/36
35
VMWARE Architecture
-
8/3/2019 Slides 2 Operating Systems
36/36
36
Reference
Chapter 1: Introduction 1.1, 1.2, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9
Chapter 2: Operating Systems StructuresAll chapter 2! 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10