A summary of all the study material for the course 'Operating systems' (2INC0) given at the TU/e. Note: I summarized all lectures except for lecture 10, as it is the best to summarize this lecture yourself once and then you'll possess enough knowledge about this material for the exam.
Lecture 1 - Why do we need an operating system?
What is an operating system?
An operating system (OS) is system software that is loaded into memory when the
computer is started. It is the software that manages communication between a
computer's hardware and software and provides a user interface.
Examples of operating system:
o Microsoft windows
o Linux
o MacOS
Why is this inefficient?
CPU wastes time when waiting for the I/O operation to complete
o Fix: execute something else on the CPU while waiting (see lecture on
scheduling)
CPU must perform many copy operations
CPU must treat many interrupts
o Fix: use direct memory access (DMA)
Using DMA:
Less operations executed by the CPU (Less interrupts to treat)
CPU can execute other useful code in parallel
A DMA may impact negatively the execution time of a program.
Does not need to copy and treat each data interrupt each time,
but still needs to know where the data is located.
So DMA does not virtualize the memory.
What is a kernel? The kernel consists of the memory, the
central processing unit (CPU) and the input/output components.
A DMA may impact negatively the execution time of a program: When a task starts memory transmission by using the DMA. The DMA and
another task which got started simultaneously might compete for a bus. They will have to share the access having half of the bandwidth.
,How does a computer work?
Someone must decide what to execute while waiting for the I/O.
Someone must ensure that the program state remains consistent when switching
between executing tasks (does not forget the task it was running before).
Someone must provide code to configure the HW (hardware) devices and treat the
interrupts.
Why do we need an operating system?
An operating system is a piece of software that acts as an intermediary between
users/applications and computer hardware.
It provides a level of abstraction that hides the gory details of the HW architecture
from applications.
It manages the sharing of HW resources among applications and users.
It optimizes performance through resource management.
Interrupts and traps
An interrupt is a signal to the CPU that transfers control to
an interrupt service routine
caused by external device (e.g. ready for i/o, i/o
completion) to tell CPU that an event happened.
interrupt vector table contains the address of the
service routine
OS preserves CPU state by storing registers and
program counter (address of the interrupted
instruction is saved)
A trap or exception is a software generated interrupt
• caused either by a software error (e.g. division by
zero, floating point error The trap handler handles
the error).
• or caused by a system call (e.g. when a program makes a system call to read a file
from memory The trap handler then handles the system call by reading the
requested file and returning the data to the program).
Dual-mode operation
Dual-mode allows the OS to protect itself and other system components.
It needs to go into kernel mode, as the system call involves accessing and manipulating
low-level system resources such as memory, processors and devices that are not accessible
to user-level programs.
Different privileges required for different types of code
o User code is executed in user mode
o Operating system is executed in kernel mode
o Most instructions can be executed in user mode, but not all.
, For instance, in user mode, the CPU cannot access memory locations
reserved for OS
o Some “privileged” instructions are only executable in kernel mode
A Mode bit is provided by hardware.
o Provides ability to distinguish when system is running user code or kernel
code.
o A system call changes the execution mode to kernel mode and when
returning from the system call it resets the mode to user mode.
Why do we need an operating system?
Deal with diversity
Transparency
Virtualization
Support for shared functionality
Portability
Support for concurrency
Deal with diversity
There are many system implementations:
diverse CPUs (Instruction Set Architectures)
diverse architectures
and organization
Multicore system: One system
containing multiple CPU's
working together.
Clustered system: One system containing two separate main memories and CPU's.
Distributed system: two systems connected via a network.
Transparency
Hide details with respect to a given issue.
Examples:
processor architecture (Instruction Set Architecture - ISA)
o mechanism: use compiler to not show the instructions.
physical memory size
o mechanism: virtual memory i.e., present linear memory model that is larger
than physical.
Location of programme and data in physical memory
o mechanism: indirection using logical (virtual) memory address.
Virtualization
Provides a simple, abstract, logical model of the system.
virtual memory, virtual CPU, virtual disk
Program can be developed as if they were the sole user of the HW resources
Current systems tend to virtualize the entire hardware
i.e., it yields a virtual machine
Virtualization can also help support several guest OS’s
on top of one host OS or on top of a given platform.
, Support for shared functionality
OS task: provide functionality common to most programs
Hardware specification: makes the
Introduce hardware transparent.
well-defined abstractions of concepts:
It tries to make anything as independent as possible from
o files and file systems instead of disk blocks
the hardware. It provides a virtual interface/model.
o exceptions and traps rather than ‘something goes wrong’
o linear memory rather than memory blocks, pages and disk space
Provide system calls to access the functions provided by the OS.
o System calls: Programming interface to the services provided by the OS
(typically written in a high-level language (C or C++))
Type of system calls:
Process management
o create, destroy, communication, synchronization, ...
File management
o open, close, read, write, ...
Memory management
o allocation, free, share memory between processes, ...
Device management
o access control, open, attach, send/receive, ....
Communications
o setup communications, exchange messages, ....
Miscellaneous
o timers, inspect system resources, ...
API vs system calls:
System calls are mostly accessed by programs via a high-level Application Program
Interface (API).
Advantage of an API over system calls:
o API works at a higher abstraction closer to programs need➔ easier to work
with.
o API calls may combine many system calls to implement higher level tasks
(e.g., copy a file) ➔ less calls needed
o A program written using an API can compile/run on any system supporting
the API ➔ portable.
Disadvantage of an API to system calls:
o Adds one more layer ➔ increased overhead, so runs slower than using
system calls
Portability
A program written using an OS or an API can compile/run on any system supporting that OS
or API:
Protect investments in application software
o Reduces cost to support several platforms
o Reduces cost to upgrade/change the execution platform
o Simplifies integration of several application components
OS gives a unified machine view to applications, effectively defining a virtual
machine.
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller LukevDongen. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $8.56. You're not tied to anything after your purchase.