System software and virtual machines Flashcards
How does the OS maximize the use of resources ?
Memory
- It moves the frequently accessed instructions to the cache for faster recall
- It makes use of virtual memory with paging or segmentation to swap memory to and from a disk
- It divides the memory into static/dynamic partitions to allow for more than one program to be available
- It removes unused items from the RAM
- It makes a partition available as soon as the process using it has been terminated
Disk
- A disk cache will hold the data that is frequently transferred
- It will decrease the file size on the disk by using compression utility so that more files can be fit on the disk
- It will use defragmentation utility so that files are rearranged to occupy contiguous spaces to reduce the data access time
How does the OS hide the complexities of the hardware from the user ?
- It gives user access to the hardware/software systems without needing the user to be involved in the complex commands, for example drag and drop in a GUI.
- It uses device drivers to synchronize the hardware
- It carries out background utilities like virus scanning
What is the need for scheduling ?
- To allow multitasking
- To ensure fair usage of the processor
- To ensure fair usage of the memory
- To ensure higher priority tasks are executed sooner
- To ensure all processors have an opportunity to finish
What are the three states of a process ?
Ready
- The process is not being executed, it is waiting in a queue for the processors attention
Running
- The process is currently using its allocated time slice and being executed by the processor
Blocked
- The process is waiting for an event so it can’t be executed at the moment, for example some input/output event
How does the kernel act as an interrupt handler ?
The kernel of an operating system acts as an interrupt handler by responding to signals from hardware devices or software conditions that require immediate attention. When an interrupt occurs, the kernel saves the current process’s state, invokes the appropriate interrupt handler to manage the interrupt (such as reading data or handling errors), and then restores the process state to resume execution. This mechanism facilitates low-level scheduling by enabling preemptive multitasking, allowing the kernel to prioritize tasks based on urgency.
How does shortest job first work ?
- The processes are executed in ascending order of the amount of CPU time required
- It leads to an increased throughput as more processes are executed per unit time
How does round robin work ?
- Each process is given the same priority and is served with a fixed time slice
- Starvation doesn’t occur and the CPU is constantly in use
How does First come first served work ?
- No complex logic, each process is queued as it is received and executed one by one
- Less procedure overhead
What is virtual memory ?
- Secondary storage is used to extend the RAM available
- So the CPU appears to be able to access more memory space than the available RAM
- Only the data in use needs to be in the main memory so data can be swapped between RAM and secondary storage as needed
- Virtual memory is created temporarily
What is a virtual machine ?
It is the emulation of a computer system using a host computer and using guest OS for the emulation
What are the pros and cons of using virtual machines ?
Pros
- A new system can be tried on the virtual hardware without needing to purchase the hardware
- You can emulate programs on the virtual machine which may not be compatible with the host operating system by using the guest OS.
- More than one computer system can be emulated which allows multiple operating systems to coexist on a single computer
Cons
- Virtual machines may be unable to emulate hardware that were developed after them
- Using virtual machines mean executing extra code which may lead to the performance degrading
- The use of virtual machines increases the maintenance overheads since both the host and guest OS must be maintained.
How does an interpreter executes a program without producing a complete translated version of it.
- An interpreter examines the source code one statement at a time
- It checks if there are any errors in the line
- If there is an error, the interpreter reports the error and halts
- Otherwise, it executes the statement
- Interpretation has to be repeated every time the program is run
What are the four stages of compilation in a program ?
- Lexical analysis
- Syntax analysis
- Code generation
- Optimisation
What is lexical analysis ?
It is the first stage in compilation,
It removes any unnecessary characters (comments) and tokenizes the program by adding new symbols to the symbol table
What is syntax analysis ?
It is the second stage in compilation,
It checks the output from the lexical analysis for any syntax errors.
If any errors are found, the statement and the error are output and code generation will not be attempted. However, if the code is error free it is passed onto the next stage