Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

39
Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems

Transcript of Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Page 1: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Operating Systems: Architecture and General

Theory

CTEC1863/2013F

Operating Systems

Page 2: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Operating System

• “a program that acts as an interface between a user of a computer and the computer hardware”

• make the computer system convenient to use• use the computer hardware in an efficient

manner

Page 3: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Some light reading ...

• http://en.wikipedia.org/wiki/Operating_system

Page 4: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Programs

• program = a set of instructions to control the computer hardware

• Most modern operating systems are written in the C language or and/or a C-like language and/or assembly language

Page 5: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Interfaces

• interface = a boundary between two layers – typically, how a "lower" layer appears to a "higher" layer.

• Interfaces exist all throughout computers.

• A "higher" layer means a higher level of abstraction – a "lower" layer often represents "nuts & bolts".

Page 6: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Interfaces (2)

Examples: – RS-232 interface (serial port)– USB interface– Application Programmer Interface (API)

• An interface exists so that a computer user does not need to know the underlying details – how the hardware "really" works.

Page 7: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Interfaces (3)

• Interestingly enough, the field of computer engineering is all about understanding both the higher and lower layers...

Page 8: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Non-computer analogy

• An automobile is a complicated machine – most drivers do not actually understand how a car really works.

• This is because, as a driver, you do not need to know what happens. You have a standard interface.

Page 9: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Human-Motor Vehicle Interface (HMVI)*

• The interface for the automobile is the steering wheel, accelerator pedal, brake pedal, gearshift, gauges (speedometer, fuel gauge, possible tachometer), turn signal, (optional) clutch pedal ...

*I made it up!

Page 10: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

... Drive!

• The bottom line: you can drive any car, from a lowly Yugo to a Formula One racer, because the interfaces on every car are similar enough!

Page 11: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

User Interface (UI)

Graphical (GUI) Command-Line (CLI)

Page 12: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Operating Systems

• In this course we are going to study three popular operating systems: Microsoft Windows, MacOS X, and Linux.

Page 13: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Operating System Interfaces

• Each presents both graphical and command-line interfaces (to the computer hardware) to the user.

Page 14: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Operating System Interfaces (2)

• Windows has the Windows Desktop, Windows Explorer, and Command Prompt

• Mac OS X has the Aqua Desktop, Finder, and Terminal

• Linux has the GNOME and KDE desktops, and various terminals

Page 15: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Operating System Interfaces (3)

• All Microsoft Windows operating systems, from Windows 95 to 7, have a similar interface.

• All UNIX operating systems, from Solaris to AIX to HP-UX to the BSDs, have a similar interface.

• All Linux operating systems, from Red Hat to Slackware to SuSE to Debian to Ubuntu, have a similar interface.

Page 16: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Operating System Interfaces (4)

• To simplify things even further, Linux and UNIX are similar (almost identical from a CLI perspective).

• Furthermore, MacOS X has BSD UNIX under the hood.

• In fact, you can run Windows, MacOS X, Solaris, and Linux on the exact same hardware!

Page 17: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Task

• “an independently-scheduled thread of execution. ” a.k.a. process, thread

• i.e., a running program

• Some programs are interactive applications, others exist in the form of services.

Page 18: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Kernel

• the code that is directly responsible for the tasking model – i.e., how the CPU's time is allocated.

Page 19: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Pre-emptive Multitasking

• The capability of an operating system to equitably share CPU time between several well-defined tasks currently scheduled to run on the system.

• All modern O/S do this!

Page 20: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Meeting the two goals …

• Be responsive to the user when running multiple tasks (allow fairly quick switching between tasks)

• Keep the CPU (and the rest of the hardware) busy at all times

Page 21: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Resource Management

Another way of looking at operating systems…• An operating system manages resources for

applications and services. (This is its only real purpose in life.)– CPU time sharing (context switching)– Memory management (virtual memory)– Hardware (timers, DMA, interrupt controllers, etc.)– Interprocess communications (IPCs)

Page 22: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Resource Management (2)

• Both applications and services are just fancy names for programs that run on a computer (in the form of tasks/processes/threads).

• In pursuing the goal of managing resources, the operating system designer walks the line between convenience and efficiency.

Page 23: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Resource #1: CPU Time

• The CPU is rated at a certain speed – way back in the day, kHz; recently, MHz; now, GHz; in the future THz (?)

CPU designers try to make their CPUs run as fast as possible using a variety of techniques: pipelining, superscaling, superpipelining, Hyperthreading, etc.

Page 24: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

CPU Time (2)

• The faster the CPU, the more instructions can be executed per second:– 1 kHz = 1,000 instructions per second* (ips)– 1 MHz = 1,000,000 ips– 1 GHz = 1,000,000,000 ips

* best case scenario

Page 25: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

CPU Time (3)

• Instructions are what make up programs.• Programs run on a computer in the form of

tasks/processes/threads.• A faster CPU means programs run faster.

(Although, not necessarily... lots of other factors!)

• An operating system is a program, made up of instructions. To get its work done, those instructions run on the CPU.

Page 26: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

CPU Time (4)

• Some operating systems try to use as little CPU time as possible, so that more of the CPU time is available for running programs.

• How efficient an operating system/CPU combination is can be measured in context switch time, typically in μs.

• The lower the context switch time, the more efficient an operating system is at managing the CPU's time.

Page 27: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Walking the Line Between Convenience and Efficiency

• Efficiency is important for real-time operating systems – that are used in applications like process control.

• It is also important in server operating systems that need to deal with high network traffic.

• Desktop operating systems place less importance on efficiency and more importance on convenience.

Page 28: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Resource #2: Memory

• There are multiple levels of memory in a computer system:

Page 29: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Memory (2)

• The operating system controls physical memory (RAM) and virtual memory (paging file or swap space – on disk).

• RAM is always at least 1,000 times faster than the fastest (mechanical) hard disk – therefore, adding more RAM will (almost always) make the operating system better able to operate efficiently and also provide a more convenient user experience.

Page 30: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Memory (3)

• For the same reason, file system caching is also used on all modern operating systems, to minimize the amount of hard disk access.

Page 31: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Resource #3: Hardware

• All devices that make up a computer system are connected to the CPU

• Programs control the CPU only; the CPU controls the hardware

• The CPU can only access instructions and data that are in RAM

Page 32: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Hardware (2)

• As important (more important for some applications!) as CPU clock speed and the amount of RAM is I/O throughput – how quickly data can be moved between RAM and the other devices – disk drives, network interfaces, etc.

Page 33: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Hardware (3)

• Throughput is also known as bandwidth.

• It is a rate, and is measured in bits per second (bps) or bytes per second (Bps), also:

– kilobits per second (kbps) / kilobytes per second (kBps)– megabits per second (Mbps) / megabytes per second

(MBps)– gigabits per second (Gbps) / gigabytes per second (GBps)

Page 34: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Interrupts

• I/O operations are typically done via interrupts – an I/O device will signal (interrupt) the CPU when it needs attention

• An operating system responds by running a program, called an interrupt service routine (ISR), made up of instructions to control the hardware device – the instructions are executed (processed) on the CPU itself.

Page 35: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Interrupts (2)

• An ISR has four responsibilities:

1. Read the status of the hardware device.2. Control the hardware device.3. Move data from the hardware device to RAM

(input).4. Move data from RAM to the hardware device

(output).

Page 36: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Interrupts (3)

• Another measure: interrupt latency – how fast the operating system/CPU combination can respond to interrupts – typically measured in µs or even ms.

• The lower the interrupt latency, the more interrupts can be processed per second. And the more data can be moved – i.e., higher throughput.

Page 37: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

Resource #4: Inter-Process Communications

• This means co-operation between tasks/processes/threads (a.k.a., running programs).

Page 38: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

IPCs (2)

– Examples:• Pipelines• "drag and drop“• Printing• helper applications/file associations• CGI applications• database-driven web sites

• The lower the IPC overhead (latency), the faster the communications (higher throughput).

Page 39: Operating Systems: Architecture and General Theory CTEC1863/2013F Operating Systems.

See the course web site for more…

http://technology.niagarac.on.ca/courses/ctec1863/