Unit 2.1 Flashcards
Why Do we need Operating Systems?
- Operating Systems manage the hardware and software resources of a computer system.
- They provide an interface between the user and the hardware, allowing the user to interact with the system and run applications.
What are the main functions of operating systems?
- Resource Management
- File Management
- Interrupt handling
- Security
- Providing a platform software to run
- Providing a user interface
- Providing utilities
What is recourse management?
- Operating systems manage the computer’s resources, including the CPU, Memory and disk drive.
- The allocate resources to specific tasks and ensure that they are used effectively
- e.g. when a user opens multiple applications, the operating systems decides:
> How much memory to allocate to each application
> When and for how long each gets to use the CPU
> How to handle data being read from or written to the hard drive.
What is file Management
- Operating systems handle the storage, retrieval, and manipulation of data files.
- When working with files, operating systems provide a GUI of the file system that allows a user to decide which directory a file should be saved in and what the file name will be.
What is interrupt handling?
- Interrupt events require the immediate attention of the processor.
- In order to maintain the smooth running of the system, interrupts must be resolved in a timely manner.
- e.g. if a user clicks cancel on a file conversion process, a signal is sent from the mouse, interrupts the processor and the operating system will trigger the cancellation routine.
What is security?
- Operating systems provide security features such as password-protected system accounts, a firewall, virus scanning and file encryption.
- Password-protected system accounts are a very common feature in operating systems.
- System accounts can also be restricted from performing certain actions, e.g. editing network settings, installing unapproved software, changing the account settings of other users.
What is Providing a platform for Software to run?
- Operating systems provide a platform on which application software can run, this is mainly by allowing software access to system resources
- e.g. if a computer game has intensive graphics and online play, the operating system will grant it access to the GPU and the network card
What is Providing a User Interface?
- Operating systems provide interaction in 2 ways: visually through a graphical user interface (GUI) or text-based through a command-line interface (CLI)
- Most modern PC operating systems provide both options, and a user will prefer one over the other depending on the task
- Mobile operating systems such as Android and iOS provide GUIs that are suitable for interaction through touch
- Ubuntu is an OS popular with software engineers because it provides a no-frills GUI and an efficient CLI
What is Providing Utilities?
- Utility programs help with system maintenance and security
- Some utility programs include: file encryption, file compression, disk defragmentation, system backup, disk cleanup
- File encryption allows users to send files over networks securely
- File compression reduces the size of a file, which helps send large files over a network
- Disk defragmentation physically reorganises files on the hard disk so they can be found and accessed faster
- Disk cleanup scans the hard disk for duplicate and corrupt files and deletes them to create more space on the disk
- Backup software allows users to restore their system to a point in history
What is Memory Management?
- Memory management is a fundamental role of the operating system, dealing with the allocation and deallocation of the computer’s primary memory
- When a user opens an application, its data is loaded from storage into active memory so that it can run smoothly
- When a user opens a file from the file system, e.g. word document, the CPU loads this file data, as well as application data, into the primary memory
- Primary memory is a limited resource in the system, so it needs careful management
- Efficient allocation of memory enables a system to continue multitasking
- Memory management is made more efficient through 3 techniques:
> Paging
> Segmentation
> Virtual Memory
What is Paging?
- Data stored in memory will lead to the smooth running of applications
- Paging is a method of chunking the primary memory into equal-sized blocks
- When an application is launched, data will be moved from the hard disk into Pages for faster access
- As users move between applications, memory is dynamically allocated
- Pages will be taken away from applications not in active use and granted to applications that are in active use
- Paging can lead to internal fragmentation
- If a 200KB file is divided into four 64KB Pages, the last Page would have 8KB of unused space
- Unused space in a Page is wasteful because other unrelated data cannot be stored in this Page
- Over time, more pockets of wasted space will exist across the memory; this process is called internal fragmentation
- The image below shows a single 64KB Page with 4KB of unoccupied space
- The box below this shows many Pages, each with varying sizes of internal fragments
What is Segmentation?
- Segmentation is a method of chunking memory into blocks that correspond to different types of data needed by an application
- A video editing application may have a Segment for video data, audio data and special effects
- Segments are not all the same size; they are sized depending on their allocated data
- Segmentation is space-efficient due to only allocating space depending on the amount an application needs
- Segmentation can lead to external fragmentation
- As Segments fill up the memory, physical gaps reduce the maximum size of new Segments that can be allocated
- Below (left) shows different application data assigned to a Segment
- The arrangement of data in the segment becomes more fragmented over time because as blocks are taken away it’s not possible to guarantee a new block will occupy the same amount of space
- Below (right) shows a defragmented version of the Segment to highlight the total unused space
What is Virtual Memory?
If a computer is running low on primary memory, it can make secondary storage act as an ‘extension’ of the main memory
The operating system can offload data from the primary memory into virtual memory
Virtual memory creates an illusion of a larger memory and enables applications to continue to multitask
However, accessing data in virtual memory is considerably slower compared to RAM
Solid-state drives are faster than traditional hard-disk drives, but neither are as fast as RAM
Over-reliance on virtual memory can lead to performance issues
What are interrupts?
- An interrupt is a signal to the processor that stops its current task and performs a different task temporarily
- Interrupts can be hardware events or time-sensitive tasks
- When an interrupt occurs, the processor suspends the current program execution and transfers control to an interrupt service routine
What is the Purpose and Role of Interrupts?
- Real-time Event Handling: hardware errors and signals from input devices e.g. hard disk failure
- Device Communication: alerts from external devices e.g. printer jams and network errors
- Multitasking: suspending processing in one application so that the user can switch to another
Explain The Interrupt Process:
Interrupt Request (IRQ)
- An external device or software generates an interrupt, signalling the processor to stop its current task
- The interrupt controller passes this to the interrupt handler for assessment
Interrupt Acknowledge
- The interrupt handler decides if the interrupt needs to be dealt with now or later
- If yes, the current contents of the processor registers are saved in memory
Interrupt Service Routine (ISR) Lookup
- The processor fetches the corresponding Interrupt Service Routine (ISR) associated with the interrupt type
ISR Execution
- The processor transfers control to the ISR and executes the routine to handle the specific interrupt
Interrupt Exit
- After the ISR completes, the processor restores the content of the registers from step 2
- The fetch-decode-execute cycle is resumed
What is an ISR?
- An ISR is a special function that handles a particular interrupt type
- Each type of interrupt has a corresponding routine, e.g. printer jam, hard disk failure, file download error, network connection error all have routines to be followed when they happen
- ISRs should be concise, efficient, and carefully designed to minimise the time taken to execute, as they often need to handle time-sensitive events