2.6 The Operating System Flashcards
Define operating system
Software that manages computer hardware and software resources
All computer programs (other than basic firmware programs) require an operating system to work
Examples:
Windows
Linux
Apple IOS, OSC
Android
What does an operating system provide
A layer of software services which are used to interact with the hardware (acts as a layer between software (and user) and the hardware
What is the kernel and what is it used for
OS can be extremely large so not all will be loaded into main memory
The kernel is the main part of the OS which is loaded into RAM when the computer boots up and this is responsible for managing processes, hardware and other important low level tasks
What are the functions of the OS
Managing resources
Memory Management
Human Computer Interface
Utilities
Security
What does manage resources include
Process Management - ensuring that different processes/programs can be run in a multitasking OS , appearing to run simultaneously using scheduling
Input/Output Management- communicating with devices such as keyboards, mice etc.
Backing Store Management- ensuring data can be read/written to disk drives, maintaining a hierarchical file system etc.
ALL OF THE ABOVE MAKE USE OF INTERRUPT HANDLING
What is the memory Management function of the OS
Ensuring programs and data can share memory and are stored correctly without interfering with each other
What is the human computer interface function of an OS
To display information to the user and accept inputs from the user
What is the utilities function of an OS
Software that comes with the OS to help with the running of the computer e.g
file Management- copy moven rename delete files and directories
Compressions software - to compress files [will be slower to open or execute each time as they will need to be decompressed]
Task managers - to view the processes/programs running, check how much processor time they are taking up and kill processes if necessary
Antivirus software - needs to be updated at least daily
Backup software - allows data to be backed up in an external drive or in the cloud
What is the security function of an OS
Typically OS has built in securities such as login/passwords, encryption, file access rights
How do operating systems have a generic way of talking to many different types of the same device (e.g. different monitors)
Hardware manufacturers produce software called hardware drivers which perform the translation between the generic OS instructions and the specific binary control signals that the hardware understands
If there isn’t a compatible driver for the OS, it won’t work
Managing backing Store
Storage devices are managed by OS which are able tor ead/write files and folders/directories and maintain a hierarchical structure, file access rights etc.
Many different formats:
NTFS (windows), FAT32(older windows), HFS Plus (Mac) all work differently
Information about files is stored in a file allocation table (FAT) which stores the location of all files on the drive together with meta data about the file( name, creation/mod date, size, access rights etc.)
Access rights
Can be set to specify which user or groups of users are able to read and/or update each file or folder
What are the different properties of a hierarchical structure in backing store
The root folder/directory can contain subfolders/directories
These subfiles can contain further files etc. Like a tree structure
They are ordered in a logical way for fast access to files and added security
Access rights can be set at a directory or file level to determine whether a particular user is able to access the folder, or if they just have read or write perm
What access rights may be given on a hierarchical structure in a school
. In a school system, a teacher may be given read access to each pupils folder
What are the different types of Human Computer interfaces
Command driven (e.g. MS-DOS)
WIMP (windows, icons, menus and pointers) e.g. Windows, apple OSX
Touch, voice etc.
Options for accessibility (to allow for easier use by people with particular disabilities)
What is a single tasking OS
The OS supervises the loading and running of one program (or process or task) at a time, and the input and output of data from and to peripheral devices
E.g. early PC running MS-DOS
Could only be used by one person at a time and could only use one program at a time
What is a batch system OS
OS that runs in batch mode will run a series of programs or jobs allocated to it in a batch file (typically left running overnight).
The transaction file once it has reached the end of its period will copy its data into the master file which will carry out its operations without human interaction
What is a multi programming OS
This OS allows more than one program to be held in main memory at the same Time.
Although the CPU can only be running the code for one program at a time, it does allow it to have one program performing Input/Output operations while it is processing another or if time slicing is used it can give each process a fair allocation of its processor time. Usually involves either or both
Multi user / multi access OS
Another form of multi programming
OS handles several different programs running at once but these programs can be owned by different users attached to the computer from terminals. The processor again allocates time slices to each program so rsch program appears to be running at the same time
Often referred to as a time sharing system
Multi tasking OS
An example of multi programming
E.g. Windows 10, where there can be different programs in memory and appearing to run at the same time. Users can switch between tasks/applications. Obviously a single processor is actually only able to run one process at a time and a time-slice based scheduling policy is used
What are the 3 different modes of operation that an OS has
Batch processing
Real time systems - control
Real time systems - transaction processing
Batch processing
When the OS executes a series of jobs without any manual intervention
E.g. thousands of pay slips or gas bills could be printed out with no human interaction
Traditionally done overnight when the computers aren’t being used for anything else (can be scheduled to run automatically)
Simpler to operate than a real time system as transactions can be stored in the order received with all processing carried out later.
Batch processing doesn’t stop for anything, any errors are written to an error log for someone to deal with the next day
What are the 4 characteristics of real time systems
They support applications which are continuous (don’t have an end)
They have to deal with events that can occur simultaneously and unpredictably
Some real time systems are safety critical. They must be fail safe, and must guarantee a response within a given interval of time
2 types of real time systems:
Real time process control
Real time transaction processing
Real time control
One of the types of real time systems
E.g. Automatic pilot on aircraft, monitoring of the production of electricity in a nuclear power station, missile guidance system, controlling traffic lights
E.g.
The coordinates of the target are set
The missiles released along its trajectory
Wind, drag etc readings are fed into input
If off target the process recalculates the trajectory, speed, direction etc. Otherwise nothing changes (example of a feedback loop)
Inputs processed quickly, processing needs to be fast enough to deliver output in time and adjusts outputs accordingly to avoid accidents
Real time control
One of the types of real time systems
Form of info processing, certainly involving accessing and updating tables in a database as part of a transaction that needs to be dealt with immediately
Transaction consists of a small number of operations that all have to be carried out one after the other - if any steps fail the entire transaction fails
More complexity than batch system as issues such as double booking and temporarily allocating records need to be considered (theatre booking system example)
What are interrupts
a signal or message from a device or software to the operating system, which may cause a break in the execution of the current routine because it is requesting attention.
they are vital in the smooth running of a computer system
What happens when an OS acknowledges the interrupt
-Suspends the current task/process carried out
- notes where to come back to so it can resume the process
-loads and runs an appropriate interrupt service routine (or handler)
what is an interrupt service routine
each type of interrupt can have one
a program or subroutine designed to deal with the situation appropriately
e.g. an interrupt from a printer reporting it is out of paper could result in an interrupt service routine displaying a message box asking the user to put more paper into the printer
name examples of interrupts
the program/process that is running can generate an interrupt to perform an input or output e.g. write data to a hard disk, send data to a printer etc.
I/O interrupt - a device can interrupt e.g. hard drive might be ready for more data or may interrupt because it has now retrieved the data that was requested
Timer Interrupt - at the end of a time-slice so a different process gets the chance to run
Restart interrupt - when the operator presses the restart or off button
Program check interrupts - These are caused by various program errors such as division by 0
Machine check interrupts - caused by malfunctioning hardware
what are interrupt priorities
some processes or interrupts are more important than others to have higher priority.
Interrupts with the highest priority have to be dealt with first so ‘jump the queue’
what are examples of interrupts with higher priority
impending data loss
impending hardware/software failure
imminent power failure detected
why are printers given high priority
they are more liable to get behind with what they do so should be allowed to start as soon as possible so they do not eventually hold up processing
what time of memory is main memory
random access memory
therefore empty when the computer is first turned on
how is main memory organised
main memory is empty when computer is turned on as it is random access
some of the OS is loaded in as the computer boots up
applications that are run are also loaded into memory
memory is also used to hold the data used by the applications as well as other things such as the run time stack which keeps track of procedure calls
what is the solution if it cause big memory problems if an application that is running changes accidently or deliberately the memory locations holding the operating system or another application
all the different things (OS, programs, stack etc. ) stored in memory need to be partitioned from each other
what are fixed sized memory partitions
used in early multiprogramming systems
main memory was divided into a number of fixed size partitions, with each partition holding a single job.
a process stayed in its partition until it was completed, and the CPU switched between the processes held in the partitions
what are the issues with fixed sized memory partitions
they waste a lot of memory as it would be unlikely that jobs exactly fill the fixed partitions
what are variable size memory partitions
where each program is allocated its own partition of the correct size
what are the problems with variable size memory partitions
once tasks are completed and as new tasks begin and they don’t take up as much space or take up too much space etc. gaps appear
Algorithms can try and find the best place to fit but this doesn’t solve the problem
Thats why in modern systems another process called paging is used
what is paging
in an os, a page table splits up the available memory into blocks of memory locations of typically 4k each
processes/programs will require a number of these pages both for the program itself and the data it needs to store
what happens in paging if the running processes require more memory than is available
if the running process require more memory than is available then a swap file is used on disk and this is also split into pages
when memory addresses are accessed within pages that are stored in disk, the OS will load them into memory and swap out pages not accessed recently into the swap file
what causes the thrashing of the hard disk
If pages are constantly being swapped in and out of memory and disk then this can slow things down and cause the thrashing noise
how are pages stored
As far as the process is concerned, memory is presented as a contiguous set of blocks with no knowledge of there being other processes in the real memory
i.e. it has its own virtual address space
e.g. if process A is putting data into page 1 the OS translates this and writes this into page 6 in real memory
if process A tries to access memory address outside the virtual address space, the OS can allocate more pages to it
what is a buffer
a buffer is an area of memory used to temporarily store data during the transfer of data to a peripheral 9e.g. printer, disk drive) or from a peripheral (e.g. a keyboard or disk drive)
why is a buffer used between a processor and a device
to compensate for the difference in speed between them
what would happen to the CPU if there weren’t any buffers
the CPU would have to constantly monitor the inputs and pass data very slowly to output devices and be completely tied up with the job it is carrying out.
e.g. if the OS had to constantly monitor a disk-drive, if it took a moment to do anything else then it may miss data being sent to it
the OS then needs to send the data a character at a time to the printer, wait until it has printed out that character and move onto the next
why is a keyboard buffer useful
if a key was pressed while the CPU is busy it isn’t missed as it it written to the keyboard buffer
the OS can then deal with it when it is ready
What is double-buffering
there can be a pause (lengthy if the OS is busy) after the disk drive has filled the buffer and it is waiting on the OS to empty it
There is also a pause after the printer has emptied the buffer while it waits for the OS to fill it with the next set of data
WHY DOUBLE BUFFERING IS USED:
situation is improved where pairs of buffers are used on each device
As soon as the disk has filled the first buffer it can start filling the second buffer without having to wait for the CPU to empty the first
therefore the e.g. disk drive should always have a buffer free
can be used continuously and doesn’t have to wait for data transfer
define spooling
clicking print send the document to a spool file on disk
a spool file acts as a virtual printer (it hasn’t been sent to a real printer yet, just to a file)
advantages of spooling
a file can be written to a disk much faster than it can be printed, making the word processor being able to be used again almost instantly
a queue of spool files can be maintained to allow the printer to deal with print queues
what is a spooler
a program that runs in the background
could be multitasking or could be on a separate file on a network
sends data from the spool file to the printer
spooler is fast and the device is slow so uses a buffer to compensate, uses a buffer again for the fast speed of the spooler and the slow speed of the printer
what is the connection between buffers and spooling
you still need buffers in a spooling system to compensate for the differences in speed between devices and processor
what is scheduling
a method by which processor time is allocated in a multi-programming (multi-task or multi-user) operating system
in this type of system several processes/programs are competing for use of the processor
at any instant only one process will be running as the CPU can only do one thing at a time, other processes will be waiting for their turn at using the processor
what is low level scheduling
when the OS has the task of deciding which process should be assigned to the CPU at any particular time.
what is the aim of the scheduler
to minimise the jobs waiting to use the processor and therefore aim to get jobs completed or using input/output as they are not then waiting to use the processor
what are the three different states that a process can be in in a multiprogramming system
ready - in a queue waiting for the processor
running - using the processor (only one process can be in this state at a time in a standard single processor system)
blocked - waiting to use (or is using) input or output (so doesn’t need the processor)
what is the high level scheduler’s job
decides if a process is allowed into the system in the first place.
It may reject a process if it requires too many resources e.g. too much memory or system is already running too many other processes
life cycle of a process
high level scheduler decides if it allowed in
process put in ready state if so
low level scheduler decides what process should be run next
running
three things may happen after this:
program ends
times-out and goes back to the ready queue
blocked (input/output) => back to ready queue once complete
what is the low level scheduler’s job
decides which process should be chosen to run next
could favour:
I/O bound processes rather than processor bound processes
try to be fair and take into account the length of time a process has been in the queue
what is time slicing
multiprogramming systems will typically allocate time-slices (finite amounts of time) to each process
when a process is running it is likely to become blocked quickly but if it doesn’t then there is a timer interrupt and the process will be put back into the ready state.
in a multi-user/multi-access system each user will get a time slice with the processor before it moves onto the next
what is round robin scheduling
ready processes are all queued in FIFO manner
if a process uses the processor longer than it is allotted time-slice, it goes to the back of the queue.
some higher priority processes could be given 2 (or more) time slices
what are multi-level feedback queues
a variation of round-robin scheduling, used in OS such as windows and MacOS
processes that use more time slice than it is allowed, it moves to the back of the queue below
time slice period in queue 1 is chosen to be large enough so that the great majority of jobs will issue an I/O request before their time slice expires.
if the time slice expires in the bottom queue, it circulates round robin until they complete
define polling
involves a computer checking whether each connected device is ready to receive data or has data to send
each terminal gets a small amount of time from the processor called a time slice
the OS switches between the different processes giving the illusion that it is running all of the tasks simultaneously
why is polling inefficient and why are interrupt driven systems better
waste time checking each device
interrupt systems are far better as in that situation each device that requires attention sends a signal to the processor and the processor can deal with each in turn if more than one interrupts.
define threading
scheduling involves the operating system managing multiple processes
modern application programming languages often make use of threading to allow a process/program to split itself into sub-processes
e.g. the opening screen of a game might play some music in one thread while at the same time displaying graphics in another
the scheduler will deal with each of these threads separately
may take advantage of multiple processors or processor cores available.
why can programming using threading be complex
it is never certain which thread will finish last. The wo threads might both need to write to the same item of data, and care is needed that this doesn’t cause an error