Important tasks of an operating system is to hide the complexities of the hardware from the users by using GUI interfaces and device drivers
The two types of multitasking operating systems are preemptive and non-preemptive
Low level scheduling - decides which process should next get the use of CPU times
Process schedular - Process priority depends on its category
Process states refer to running, ready and blocked
The conditions when changing from one process to another is
running state --> ready state
ready state --> running state
running state --> blocked state
blocked state --> ready state
Memory management - determines which processes should be in main memory and where they should be stored (optimisation)
Single/contiguous allocation - All of the memory is made available to a single allocation
Paging - The memory is split up into partitions of a fixed size. Physical memory blocks are known as frames and fixed sized logical memory blocks are known as pages.
Segmentation - Logical address space is broken up into variable size memory partitions called segments. Segments from logical memory are loaded into physical memory
Differences between paging and segmentation:
A page is a fixed size block of memory
A segment is a variable size block of memory
The process of paging is invisible to the user
The process of segmentation is visible to the user
Multitasking - managing the execution of many programs that appear to run at the same time
Paging - reading/writing same sized blocks of data from/to secondary storage when required
Interrupt handling - Transferring control to another routine when a service is required
Scheduling - managing the processes running on the CPU
Virtual memory - using secondary storage to stimulate additional main memory
Disk thrashing - an issue occurring when the hard drive is overworked by transferring information between the system memory and the virtual memory. This swapping leads to a very high rate of hard disk head movements
A virtual machine is the emulation of an existing computer system
pros on virtual machines:
There are security benefits
Cost savings due to not needing to buy extra hardware
Cons on virtual machines:
Costly to maintain
Cannot emulate some hardware
Explain how an interpreter executes a program without producing a complete translated version of it:
An interpreter examines source code one statement at a time. Check each statement for errors. If no error is found the statement is executed. If an error is found this is reported and the interpreter halts. Interpretation has to be repeated every time the program is run
The 4 stages of compilation:
lexical analysis
syntax analysis
code generation
optimisation
Lexical analysis: the first stage in the process of compliation. It removes unnecessary characters and tokenises the prgram
Syntax analysis: the second stage in the process of compilation. The output from the lexical analysis is checked for syntax errors
Code generation: the third stage in the process of compilation. This stage produces an object program
optimisation: the fourth stage in the process of compilation. The creation of an efficient object program
Explain why RPN is used to carry out the evaluation of expressions:
RPN reads from left to write and doesn't use brackets
What data structures can be used to evaluate an expression in RPN:
Stack
binary tree
Outline the purpose of syntax analysis:
Checks for grammar errors and syntax errors.
A parse tree is produced
Outline the reasons why an operating system may need to use virtual memory:
Virtual memory is used when RAM is running low such as when a computer is running many processes at once.
Explain how an expression stored in RPN can be evaluated:
The RPN value reads from left to right one item at a time. Items are pushed onto the stack until an operator is found. This process is iterated.
Justify the use of a linked list instead of an array to implement a stack:
A linked list is a dynamic structure. It allows more efficient editing using pointers
Explain how a compiler makes use of a stack when translating recursive programming code:
The compiler code must produce object code to push values onto a stack with each recursive call and pop values off the stack after the base case is reached.