Operating Systems Flashcards

(91 cards)

1
Q

What is an operating system?

A

A software that acts as an interface between the user and hardware- mangaes resources and lets programs run

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why are operating systems important?

A
  • Helps separate different parts of a system
  • Allow devices to be used in flexible ways
  • Make it possible for programs to run on different hardware types without changes
  • Manages process
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an API?

A
  • Application Programming Interface
  • Set of tools and functions that let programs talk to the OS
  • Hides complex parts of how the system works (abstraction)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the types of memory allocation?

A

Static: Size is fixed before the program runs
Dynamic: Size can change while the program is running

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What manages memory allocation?

A

Memory can be managed either by the application or by the OS itself

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the Memory Management Unit do?

A

MMU helps manage memory by:
- Translates virtual to physical addresses
- Controlling access to memory
- Handling read/ write actions
- Storing permissions
- Dealing with memory errors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is memory protection and why is it needed?

A
  • Memory protection stops programs from changing memory they shouldn’t
  • Checks access using virtual addresses and processor permissions to keep the system safe
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the types of memory permissions?

A
  • No access: Not allowed to access
  • Read-only: Can read but not change
  • Supervisor read/ write: Only the system can change it
  • Read/ write: Full access to read and change
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose of memory management in processes?

A

To ensure processes remain independant and have controlled access to resources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does each process have to prevent interference?

A

Its own address space for reading and writing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What type of addresses do processes use and how are they handled?

A

They use virtual addresses which system maps to physical memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How are addresses translated in memory mapping?

A
  • Organised into software pages
  • MSB of address defines the page number
  • Only the page number is translated
  • Some pages can be invalid (not mapped to RAM)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are base and limit registers used for?

A

Base: Start of physical address
Limit: Size of the memory range

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens when physical memory is full?

A

Swapping/ paging moves some pages to disk to free space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why is RAM important for reducing swapping?

A

Because swapping is slow, more RAM reduces the need for it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the memory allocation strategies for a new process?

A

First fit: Fast but can cause fragmentation
Best fit: Efficient but more complex
Worst fit: Uses the largest gap, may leave leftover space

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is external and internal fragmentation?

A

External: Enough free memory exists but not in one contiguous block- requires reorganisation
Internal: Unused memory in partitions; memory is seperated in blocks, not individual locations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Why is virtual memory used?

A

Virtual memory allows more processes to run without frequent swapping. Efficient mapping is needed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are the 2 locality principles?

A

Spacial locality: Nearby addresses likely used soon
Temporal locality: Recently used addressed likely used again

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How do caches work and why is flushing important?

A
  • Caches store frequently accesssed data near the CPU to improve speed
  • Intercept known requests and store unknown ones for future use
  • Flushing to avoid context switches, where a virtual address may change its meaning
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How is a virtual address structured?

A

Virtual address = Page number (MSB) + Offset (location in page)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How are virtual addresses translated?

A
  • Page tables map virtual pages to physical ones
  • 2^32 locations with 4KiB (2^12) pages- 2^20 entries
  • TLB caches recent translations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How are pages mapped efficiently?

A
  • Sparse data structures are used to fill only necessary table entries
  • Hierarchal paging follows pointers between branches
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a page fault and how is it handled?

A
  • If page is not in memory MMU triggers a page fault + causes OS call
  • Page must be swapped from disk, but time consuming so can be offloaded to DMA
  • Page tables must be updated accordingly
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Explain page evicting
- Pages can be evicted to make space for new pages - Copied pages can be overwritten and clean pages can be evicted easily
26
How is hashing used for address translation?
- Hash function maps data to fixed size values - Surjective not injective - leads to collisions which are resolved via buckets - Hashed page tables map logical to physical addresses
27
What is an inverted page table and how does it differ?
- Maps physical frames to virtual pages - Useful for reducing memory used for page tables
28
What is cache and why is it useful?
- Remembers and **stores** information, between the client and service - Cuts out extra communication - Recuded **distance** and computation **cost**
29
What are the two problems with cache?
- **Cache gets full**: needs policy for replacing things - **Cache goes stale**: need to know when to flush
30
Standard swapping vs swapping with paging
**Standard:** - **Whole process** moves out and OS maintains metadata for swapped pages - Takes a lot of time **Swapping with paging:** - Swaps out **individual pages** associated with a process
31
Explain page lookups
- **MMU** takes virtual address and finds appropriate page (if not there raise page fault) - OS checks virtual address and **permission** - If there are no frames in the cache then we need to **evict**
32
Explain how pages are monitored
- On first read: mark pages as read only - On first write: raise page fault and change permissions - If page it writable it must have been changed- if not it can be overwritten
33
What is the DMA controller and why is it used?
- Direct memory access - Allows hardware devices to move data directly to or from memory **without CPU** - Handles data movement once CPU sets up transfer
34
What are the uses of DMA?
- Large block I/O transfers - High bandwidth device communication - Memory to memory copying - Speed and efficiency during swapping
35
What is the role of the DMA controller during swapping?
- Physically moves pages into memory while CPU does other things - Works outside MMU and can generate interrupts and raise faults for OS to handle
36
What is shared memory and its drawbacks?
- Shared memory is the idea that two processed might be stored in the **same** bit of **physical** memory - Raises **data concerns** but can access memory through memory **mapping** so they are **treated** like they are part of their **own address space**
37
What are the benefits of shared memory?
- **Interprocess communication**: Processes can exchange data - **Shared libraries** - **Share read-only data**
38
What are the benefits of a library?
- Expose OS **functionality** - Allow code to be **agnostic** to underlying system (only need to know syscalls or API)
39
Explain static libraries
- Library code included in application at **compile time** - Self-contained
40
Explain dynamic libraries
- Library **loaded** when process is **running** - Involves **linker** at execution - **More management** required but **easier maintenance**
41
What are the two features libraries should have?
- **Re-entrant**: No visible side-effects - **Relocatable**: No absolute addresses and code can be executed at any address
42
What three things are a process comprised of?
- An executing program - Its files - Its permissions
43
What is the context of a process and how is it stored?
- The **environment** in which the process operates - Including its **variables** and **resources** - Kept in **memory** within PBC
44
What is the role of the scheduler?
- Manages a process' **status** - (eg. New, Ready, Running, Waiting, Terminated)
45
What is the PCB?
- Process control block - Contains process ID, registers, memory addressed and **info about a process** - Allows OS to pause, save and resume processes accurately
46
What is context switching, and how does the scheduler determine when it happens?
- Context switching saves the current process' state and loads another's - Triggered when a process finishes, blocks or there is a higher priority process - Enables efficient **multi-tasking**
47
What happens during the waiting stage of a process, and why is it important?
- Waiting allows a process to access external resources without wasting CPU time - No other processes are **interrupted**
48
What is a ready queue and when is it formed?
- Forms when multiple processes are ready to execute - Scheduler selects processes from queue to run
49
What can happen when a process is in the **Ready**, **Running** or **Blocked** state?
- **Ready**: Scheduled by OS ot terminated externally - **Running**: Can yield execution, complete or be terminated externally - **Blocked**: Become unblocked or terminated externally
50
What is real-time processing and how does it differ between hard and soft real-time tasks?
- Real time processing (**FIFO**): Jobs are queued and executed in order - **Hard** failure causes **system failure** - **Soft** failure causes **inconvenience** - Schedulers prioritize real-time tasks
51
What is shortest job next scheduling and what does it require?
- Prioritises samller tasks to maximise efficiency - Minimises waiting time across jobs - Requires knowledge of job's size beforehand
52
What is the fork function and what does it do?
- System call - Created child process from parent process
53
What are the 3 steps to process creation?
1. Parent process calls fork() 2. Child process inherits most of parent's attributes 3. After fork, parent and child execute different code paths
54
Explain the PID and executions of both the parent and child processes
**Parent**: recieves child's PID and continues execution after fork() **Child**: recieves 0 as PID and proceed with its own execution or use system calls
55
What are daemon processes?
- Operate independently of user interaction - Responsible for crucial system function (eg. init/systemd/launchd)
56
Give the 7 fields in the PCB
- **Process ID**: identifier for process - **Parent Process ID** - **Priority**: scheduling priority - **Registers**: register values (acc, pc) are saved here during context switching - **Memory Info:** info about memory alloc. (pointers etc) - **Resource pointers:** pointers to devices/resources - **State of process**
57
How do the child and parent processes terminate?
- **Child**: executes exit() and passes exit status to parent - **Parent**: retrieves child's exit status using wait() and cleans up resources
58
What are zombie processes?
- When process **terminates** but parent has **not yet called wait()** to collect exit status - **Occupies system resources** until parent calls wait
59
What are orphaned processes and how are they managed?
- When a child loses its parent (terminates unexpectedly) - init process adopts orphaned processes
60
How is memory allocated and what is fragmentation?
- Memory allocated will malloc() - Fragmentation occus when memory is allocated and freed in non-contiguous manner (inefficient memory usage)
61
What are the four deadlock conditions and explain each?
- **Mutual exclusion**: One process can use a resource at any given time - **Hold and wait**: Process holding one resource is waiting to aquire additional resources - **No pre-emption**: Resource cannot be forcibly taken from processes - **Circular wait**: Circular dependancy of each process to release a resource
62
What is deadlock?
When a set of processes are blocked because each is waiting for another to release a resource
63
Give the 4 methods of avoiding deadlock
- **Ignore**: in systems where it is rare - **Prevent**: eliminate one of the four conditions - **Avoid**: system calculates whether granting a request will lead to deadlock - **Detect and fix:** system periodically checks for cycles that would cause dealock- resolved by killing process, rolling it back or pre-emption
64
Give 4 file attributes
- **Size** - **Timestamps**: creation time, last modified time, last accessed time - **Permissions**: who can access and modify a file - **Ownership**
65
Give and explain the 4 file categories
- **Regular files**: text files, binary, exe - **Diretories**: contain refs to other files - **Symbolic links**: point to another file or dir - **Special files**
66
Give and explain 3 types of special file
- **Named pipes**: interprocess communication - **Sockets**: communication between processes - **Device file**: represent physical or virtual devices
67
What is the difference between a hard and a symbolic link?
- Hard links are **direct references to a file's data** blocks (links to i-node) whereas symbolic links are **seperate files that contain another path** pointing to another file or directory - Deleting a hard link does not remove the actual file unless **all** links are removed - If the target file is deleted or moved, the symlink becomes **broken**
68
Give and explain 3 types of special permissions
- **Setuid**: allows a program to execute w/o owner permissions - **Setgid**: allows a program to execute without the permissions of its group - **Sticky bit**: ensures only the file's owner can delete or modify it
69
What is an ACL?
- Access control lists - List of entries that **specify permissions** for special users or groups - Useful whe there are multiple users with different roles
70
Explain what a volume is and how it is moves
- A volume is a logical drive (often corresponds to a disk partition) - Moving files within a volume: requires renaming - Moving between volumes: full data copying
71
What is an i-node?
- **Fragmentation** scheme (for file implementation) - Contains some file attributes and array of **pointers** - Small so limited no. of blocks (can link to other blocks w hard and soft links)
72
What is the difference between file descriptors vs attributes?
- Attributes are **permanent** and exist when file is not in use - Can be **multiple** file descriptors but one set of attributes
73
What are file descriptors and what do they hp;d?
- Created when a file is opened - Hold: access permissions: position/index of file, error status, control flags
74
Give and explain two types of file systems
- **Flat file system**: files stored in single directory without hierarchat organization - **Hierarchial file system**: files are organised into directories
75
Give and explain 2 features of C
- **Imperative**: sequences of statements executed in order - **Typed**: variables declared with a type
76
Explain arrays in C
- Collection of **same-sized** items - Stored **sequentially** in memory - Interchangable with pointers
77
Explain structures/records in C
- Structs have elements that are accessed via their **names** rather than indiced - Elements can be **different sizes**
78
What is virtualisation?
- Refers to creating an illusion where processes and applications believe they hav e sole access to resources - Multiple processes actually share resources
79
Give 4 motivations for virtualisation
- **Testing and experimentation**: no need to install them of physical devices - **Security**: virtual machines can be sandboxed- allows for safe testing - **Legacy software support:** running outdated software - **Digital preservation**: helps preserve old formats
80
What is the purpose of abstraction?
- Operating systems abstract physical hardware to simplify resource management - Hides details such as memory management and process scheduling
81
What are examples of abstraction in operating systems?
- **File System**: hierarchal structure representing files - **Processes**: multiple processes managed by os - **Virtual memory**: processes use virtual addresses which may be mapped to physical memory
82
What is a hypervisor?
- Software that enables **multiple virtual machines** to run on a **single** physical computer - Provides a **further layer** between operating system and hardware
83
What is a type 1 and type 2 hypervisor?
Type 1: - **Bare metal** - Runs **directly** on physical hardware - Manages multiple guest OSs Type 2: - Hosted - Runs as an **application** on existing OS
84
What are the differences of type 1 and 2 hypervisors in terms of performance and uses?
- Type 1 has **better performance** as it has direct hardware access whereas type 2 has more layers - Type 1 typically used in **large scale environments** but type 2 is suitable for **personal** or development environments
85
Give 4 ways to run multiple operating systems
- **Hypervisor** - **Bootloader** for dual-boot systems - **Virtual machines and emulators** to run multiple systems/ simulate older systems
86
What is emulation?
- Creating a **model of hardware** + its components - Runs on top of libraries - Replicate older systems
87
What is cloud computing?
- Provides **remote services and data** to users - Allows users to deploy applications without concern for hardware - **Abstracts** infrastructure while cloud provider manages resources
88
What is the difference between cloud computing and virtulisation?
- Cloud computing is about offering remote services and data storage **rather than** the illusion of physical hardware
89
What are virtual networks?
- Abstract physical connections between devices - Provides **greater flexibilty** and resource management in networks
90
Give and explain the two types of virtual networking
- **Extended virtual networks**: creating logical networks from physical network components - **Internal virtual networks**: VMs can be made to communicate over a virtual network- simualtes physical connections between devices
91
What is tunneling?
- **Encapsulating data** from one protocol within another - Allows **protocols** to be used in environments that require a different one - **VPNs** utilise tunneling techniques to transmit data