0% found this document useful (0 votes)
27 views36 pages

OS Structures and Clocks

The document discusses different operating system structures, including monolithic systems, layered systems, microkernels, client-server systems, virtual machines, and exokernels. Monolithic systems run the entire OS as a single program, layered systems organize the OS in a hierarchy of layers, and microkernels split the OS into small, well-defined modules with most running as user processes. Client-server systems use servers to provide services to clients, often through message passing. Virtual machines allow multiple OSes to run on the same physical machine through virtualization.

Uploaded by

Xpds
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views36 pages

OS Structures and Clocks

The document discusses different operating system structures, including monolithic systems, layered systems, microkernels, client-server systems, virtual machines, and exokernels. Monolithic systems run the entire OS as a single program, layered systems organize the OS in a hierarchy of layers, and microkernels split the OS into small, well-defined modules with most running as user processes. Client-server systems use servers to provide services to clients, often through message passing. Virtual machines allow multiple OSes to run on the same physical machine through virtualization.

Uploaded by

Xpds
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Operating System Structure

1. Monolithic systems
2. Layered systems
3. Microkernels
4. Client- server systems
5. Virtual machines
6. Exokernels

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Monolithic Systems
The entire operating system runs as a single program in kernel
mode.

The operating system is written as a collection of procedures,


linked together into a single large executable binary program.

In addition to the core operating system that is loaded when the


computer is booted, many operating systems support loadable
extensions, such as I/O device drivers and file systems. These
components are loaded on demand e.g. shared libraries in Linux
and dlls in Windows.

Basic structure of OS
1. A main program that invokes the requested service procedure.
2. A set of service procedures that carry out the system calls.
3. A set of utility procedures that help the service procedures.

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Monolithic Systems

A simple structuring model


for a monolithic system.

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Monolithic Systems

Examples :

Linux, Microsoft Windows, etc.

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Monolithic Systems
Linux Operating System

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Monolithic Systems

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Monolithic Systems

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Layered Systems
The operating system is organized as a hierarchy of layers, each
one constructed upon the one below it, e.g. the THE system built
at the Technische Hogeschool Eindhoven in the Netherlands by E.
W. Dijkstra (1968) and his students.

Structure of the THE operating system.

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Layered Systems
MS - DOS

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Microkernels
The basic idea is to achieve high reliability by splitting the
operating system up into small, well-defined modules, only one of
which—the microkernel—runs in kernel mode and the rest run as
relatively powerless ordinary user processes.

Simplified structure of the MINIX 3 system.


Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Microkernels
Examples:

Minix, HelenOS, Horizon, The L4 microkernel family, Zircon (Fuchsia


OS).

MINIX 3
Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Client-Server Model
• Servers provide some service.
• Clients use these services.
• Communication between clients and servers is often by message
passing.

• Client-server model is an abstraction that can be used for a


single machine or for a network of machines.

The client-server model over a network.


Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Virtual Machines
Virtualization allows you to run two or more operating systems
using only one machine.
Before Virtualization: Many companies have traditionally run
their mail servers, Web servers, FTP servers, and other servers
on separate computers.
After Virtualization: They can run many servers on the same
machine without having a crash of one server bring down the
rest.
Web hosting world:
o NO Virtualization
Shared hosting, a login account on a Web server, but no
control over the server software
Dedicated hosting, you have your own machine, very
flexible but not cost effective.
o With Virtualization
Each customer can have different fully controllable
operating systems on the same machine.

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Virtual Machines
Virtual Machines

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Virtual Machines

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Virtual Machines

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Virtual Machines
Control Program/Cambridge Monitor System (CP/CMS)

App
CMS is a single user OS

The structure of VM/370 with CMS.

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Virtual Machines Rediscovered

(a) A type 1 hypervisor. (b) A pure type 2 hypervisor. (c) A practical type 2
hypervisor.

Hypervisor (virtual machine monitor)

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Virtual Machines Rediscovered
Type 1 hypervisor
Example:
ESXi (Elastic Sky X Integrated):

1. Type-1 hypervisor
2. Runs directly on system hardware
3. No need for an operating system (OS)

Tanenbaum & Bo, Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Virtual Machines Rediscovered
Type 2 hypervisor(VirtualBox)

Host OS (Windows 10) Guest OS (Tiny Core Linux)


Virtual Machines Rediscovered
Real or Virtual machine(type 1 or 2)?
Clocks (Timers)

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Hardware
Clocks are built out of three components:

1) Crystal oscillator
Can generate a periodic signal, typically in the range of
several hundred megahertz to a few gigahertz, depending on the
crystal chosen.

2) Counter
This signal is fed into the counter to make it count down
to zero. When the counter gets to zero, it causes a CPU
interrupt.

3) Holding register
The value of the holding register is copied into the counter.

All the clock hardware does is generate interrupts at known


intervals.

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Hardware

A programmable clock.

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Hardware

One-shot mode
When the clock is started, it copies the value of the holding
register into the counter and then decrements the counter at each
pulse from the crystal. When the counter gets to zero, it causes
an interrupt and stops until it is explicitly started again by
the software.

Square-wave mode
After getting to zero it causes an interrupt, the value of the
holding register is copied into the counter and whole process is
repeated again indefinitely. These periodic interrupts are called
clock ticks.

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Hardware

The advantage of the programmable clock is that its interrupt


frequency can be controlled by software.

If a 500-MHz crystal is used, then the counter is pulsed every 2


nsec. With (unsigned) 32-bit registers, interrupts can be
programmed to occur at intervals from 2 nsec to 8.6 sec.

T = 1/f = 1/(500 x 106) sec = 109 /(500 x 106) nsec = 2 nsec


32-bit register (232-1) x 2 nsec = 8,589,934,590 nsec ≈ 8.6 sec

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Software

Typical duties of a clock driver:

1. Maintaining the time of day.


2. Preventing processes from running longer than allowed.
3. Accounting for CPU usage.
4. Handling alarm system call from user processes.
5. Providing watchdog timers for parts of system itself.
6. Profiling, monitoring, statistics gathering.

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Software
Maintaining the time of day

Time of day in ticks


Clock rate f = 60 Hz and a 32-bit counter
T = 1/f = 1/60  0.0167 second
The largest unsigned 32-bit binary number = 232 – 1 = 4294967295
Total time = 42949672950.0167 = 71725953.8265 seconds = 2.274 years
Will overflow in just over 2 years.

The largest unsigned 64-bit binary number = 264 – 1


Total time = (264 – 1)0.0167 = 9768538369.8297023773 years

Makes maintaining the counter more expensive since it has to be


done many times a second.

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Software
Maintaining the time of day

Time of day in seconds

The time of day is maintained in seconds, rather than in ticks.


Clock rate f = 60 Hz and a 32-bit counter
1 second = 60 ticks
The largest unsigned 32-bit binary number = 232 – 1 = 4294967295
Total time = 42949672951 = 4294967295 seconds  136 years
Will work until the twenty-second century.

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Software
Maintaining the time of day

Count in ticks, but to do that relative to the time the system


was booted, rather than relative to a fixed external moment.

Current time = the stored time of day in the memory + counter

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Software

Preventing processes from running longer than allowed

Whenever a process is started, the scheduler initializes a counter


to the value of that process’ quantum in clock ticks. At every
clock interrupt, the clock driver decrements the quantum counter by
1. When it gets to zero, the clock driver calls the scheduler to
set up another process.

Accounting for CPU usage

Start a second timer, distinct from the main system timer, whenever
a process is started up. When that process is stopped, the timer
can be read out to tell how long the process has run. To do things
right, the second timer should be saved when an interrupt occurs
and restored afterward.

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Software
Handling alarm system call from user processes

In many systems, a process can request that the operating system


give it a warning (a signal, interrupt, message,…) after a certain
interval. If many signals are expected, it is more efficient to
simulate multiple clocks by chaining all the pending clock requests
together, sorted on time, in a linked list.

Each entry on the list tells how many clock ticks following the
previous one to wait before causing a signal.

Example:

Signals are pending for 4203, 4207, 4213, 4215, and 4216.

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Software
Handling alarm system call from user processes

Example:

Signals are pending for 4203, 4207, 4213, 4215, and 4216.

the next interrupt occurs in 3 ticks. On each tick, Next signal


is decremented. When Next signal = 0, the signal corresponding to
the first item on the list is caused, and that item is removed
from the list. Then Next signal = 4.

Simulating multiple timers with a single clock.

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Clock Software

Providing watchdog timers for parts of system itself

Detect and recover from crashes, infinite loops Example: For


instance, a watchdog timer may reset a system that stops running,
especially used in embedded system.

https://www.youtube.com/watch?v=GC6dGypGctQ

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.
Linux

sysconf(_SC_CLK_TCK)

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.

You might also like