week 5 os theory Flashcards
what are the two valid os descriptions:
A program that acts as an intermediary between a ‘user’ of a
computer and the computer hardware
The one program that is at all times running on the computer,
with all else being systems programs and application programs
main fucntions of an os
resource allocator
control system
describe os as a resource allocator
Manages all hardware resources and decides between
conflicting requests for efficient and fair resource use
(e.g. accessing CPU, disk or other devices)
describe os as a control system
Controls execution of programs to prevent errors and
improper use of the computer (e.g. protects one user
process from crashing another)
define bootstrapping of os
Small bootstrap program is loaded at power-up or reboot
Typically stored in ROM or EPROM, generally known as
firmware (e.g. BIOS)
Initializes all aspects of the system (e.g. detects connected
devices, checks memory for errors, etc.)
Loads operating system kernel and starts its execution
ROM = Read Only Memory
EPROM = Erasable Programmable ROM
BIOS = Basic Input/Output System
what does ROM stand for
Read Only Memory
what does EPROM stand for
EPROM = Erasable Programmable ROM
what does BIOS stand for
BIOS = Basic Input/Output System
define sharing among reources in os (3 points )
Device controllers are hardware within laptop/computer
needed to connect to external resources
Bus (the ‘wire’) connects CPUs, device controller and memory
OS Kernel runs within the CPU and manages the devices
through the device controllers
define device contollers when sharing among resources
I/O devices and the CPU can execute concurrently
Each device controller (e.g. controller chip) is in charge of a
particular device type
Each device controller has a local buffer (i.e. memory store for
general data and/or control registers)
CPU moves data from/to main memory to/from controller
buffers (e.g. write this data to the screen, read coordinates
from the mouse, etc.)
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
decribe aht an interrupt is
Interrupts can be implemented in different way, but a common
approach is through an interrupt vector
Interrupt Vector is a reserved part of the memory, tracking
which interrupts need to be handled
For each interrupt, the OS executes the appropriate ‘Interrupt
Service Routine’ to handle the interrupt
The address of the interrupted instruction is saved so original
processing can be resumed after completion of the interrupt
Software programs can also generate interrupts, through
system calls, for instance when an error occurs. A
software-generated interrupt is called a trap
what does main memory store
large storage media that cpu can access directly
what does secondry storage store
provides large non volatile storage capacity
give importat example of secondary storage
Important example: magnetic disks - rigid metal or glass
platters covered with magnetic recording material
Disk surface is logically divided into tracks, which are
subdivided into sectors
The disk controller determines the logical interaction between
the device and the computer
Today also often flash memory. However, same logical division
intro tracks and sectors still used
how do users interact with os
Users interact indirectly through a collection of system
programs that make up the operating system interface. The
interface could be:
A GUI, with icons and windows, etc. Nowadays, this is the
norm.
A command-line interface for running processes and scripts,
browsing files in directories, etc. For Computer Scientists only
how do processes interact with os
Processes (the programs in execution) interact with the
Operating System by making system calls into the operating
system kernel.
Though we will see that, for stability, such calls are not direct
calls to kernel functions
state the 4 processes os offers
Program execution
I/O operations
file system manipulation
Interprocess Communication (IPC)
what is program execution
The system must be able to load a
program into memory and to run that program, end execution,either normally or abnormally (indicating error)
what is i/o operations :
A running program may require I/O, which
may involve a file or an I/O device
File-system manipulation: Programs need to read and write
what is file system manipulation
programs need to read and write
files and directories, create and delete them, search them, list
file Information, permission management.
what is interprocess communication (IPC)
Allowing processes to
share data through message passing or shared memory
what are the fours services for os itself
Error handling
Resource allocation
Accounting
Protection and Security
what is error handling
managing errors like if function dives by zero etc
what is accounting
e.g. how much disk space is this or that user using? how much network bandwidth are we using?
what is resource allocation
Resource allocation: Processes may compete for resources such as the CPU, memory, and I/O devices.
what is protection and security
The owners of information stored in a multi-user or networked computer system may want to control use of that information, and concurrent processes should not interfere with each other
describe system calls
Programming interface to the services provided by the OS
(e.g. open file, read file, etc.)
Typically written in C (or C++)
Mostly accessed by programs via a high-level Application
Program Interface (API) rather than direct system call.
Two common APIs: Win32 API for Windows, POSIX API for
UNIX-based systems (including virtually all versions of UNIX,
Linux, and Mac OS X).
The APIs allow application code to access the kernel without
requiring root privileges: it transfers control from user mode
to kernel mode
what are the system calls for file operations
open
read
write
close
what is open in system call
Register the file with the operating system. Must be
called before any operation on the file. Returns an
integer called the file descriptor - an index into the
list of open files maintained by the OS.
what is read in system call
Read data from the file. Returns number of bytes
read or 0 for end of file.
what is write in system call
Write data to a file. Returns number of bytes written.
what is close in system call
De-registers the file with the operating system. No
further operations on the file are possible
what do the file operations in system call return when they get an error
return negative number
what can we use to see if there is an error in the file operations in sc
perror
describe trapping to kernel
Trapping to the Kernel
The user process calls the system call wrapper function from
the standard C library
The wrapper function issues a low-level trap instruction (in
assembly) to switch from user mode to kernel mode
There is some ‘magic’ happening to move from user mode to
kernel mode:
To get around the problem that no call can directly be made
from user space to a specific function in kernel space:
Before issuing the trap instruction, an index is stored in a well
known location (e.g. CPU register, the stack, etc.).
Then, once switched into kernel space, the index is used to
look up the desired kernel service function, which is then called.
Some function calls may take arguments, which may be
passed as pointers to structures via registers.
describe traditional unix
UNIX - one big kernel
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
Limited to hardware support compiled into the kernel
describe modular kernel
Most modern operating systems implement kernel modules
Uses object-oriented–like approach
Each core component is separate
Each talks to the others over known interfaces
Each is loadable as needed within the kernel, so you could
download a new device driver for your OS and load it at
run-time, or perhaps when a device is plugged in
Overall, similar to layered architecture but with more
flexibility, since all require drivers or kernel functionality need
not be compiled into the kernel binary.
Note that the separation of the modules is still only logical,
since all kernel code (including dynamically loaded modules)
runs in the same privileged address space (a design now
referred to as monolithic), so I could write a module that
wipes out the operating system no problem.
This leads to the benefits of micro-kernel architecture, which
we will look at soon
describe microkernel
Moves as much as possible from the kernel into less privileged
“user” space (e.g. file system, device drivers, etc.)
Communication takes place between user modules using
message passing
The device driver for, say, a hard disk device can run all logic
in user space (e.g. decided when to switch on and off the
motor, queuing which sectors to read next, etc.)
But when it needs to talk directly to hardware using privileged
I/O port instructions, it must pass a message requesting such
to the kernel
benefits of microkernels
Easier to develop microkernel extensions
Easier to port the operating system to new architectures
More reliable (less code is running in kernel mode) - if a device
driver fails, it can be re-loaded
More secure, since kernel is less-complex and therefore less
likely to have security holes.
The system can recover from a failed device driver, which
would usually cause “a blue screen of death” in Windows or a
“kernel panic” in linux
con of microkernel
Performance overhead of user space to kernel space
communication
example of microkernel
The Minix OS and L3/L4 are examples of microkernel
architecture
describe virtual machines
A virtual machine allows to run one operating system (the
guest) on another operating system (the host)
A virtual machine provides an interface identical to the
underlying bare hardware
The operating system host creates the illusion that a process
has its own processor and (virtual) memory
Each guest is provided with a (virtual) copy of underlying
computer, so it is possible to install, say, Windows 10 as a
guest operating system on Linux.
describe paravisulisation
Presents guest with system similar but not identical to
hardware (e.g. Xen Hypervisor)
Guest OS must be modified to run on paravirtualized
’hardware’
For example, the kernel is recompiled with all code that uses
privileged instructions replaced by hooks into the virtualisation
layer
After an OS has been successfully modified, para-virtualisation
is very efficient, and is often used for providing low-cost rented
Internet servers (e.g. Amazon EC2, Rackspace
describe VMWare Architecture
VMWare implements full virtualisation, such that guest
operating systems do not require modification to run upon the
virtualised machine.
The virtual machine and guest operating system run as a
user-mode process on the host operating system
As such, the virtual machine must get around some tricky
problems to convince the guest operating system that it is
running in privileged CPU mode when in fact it is not.
Consider a scenario where a process of the guest operating
system raises a divide-by-zero error.
Without special intervention, this would cause the host
operating system immediately to halt the virtual machine
process rather than the just offending process of the guest OS.
So VMWare must look out for troublesome instructions and
replace them at run-time with alternatives that achieve the
same effect within user space, albeit with less efficiency
But since usually these instructions occur only occasionally,
many instructions of the guest operating system can run
unmodified on the host CPU