1.2.1 Operating Systems Flashcards

(22 cards)

1
Q

Why is an operating system needed?

A

An OS is needed to manage hardware, provide a platform for software, handle resources, ensure security, manage files, manage memory, schedule tasks, handle interrupts, and provide a user interface.

It acts as the intermediary between user programs and hardware.

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

Core functions of an operating system

A
  • Memory management
  • Processor scheduling
  • File/disk management
  • Device management + drivers
  • Interrupt handling
  • Security + access rights
  • Providing a user interface
  • Providing utilities (e.g., compression, antivirus, defrag)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are drawbacks or limitations of operating systems?

A

Complex OSs require more hardware resources (RAM, CPU).

Bugs in the OS can impact entire system stability.

Security vulnerabilities can be exploited if not updated.

Hard-to-learn interfaces (e.g., CLI) can reduce usability.

Strict OS rules limit direct hardware access for programmers.

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

What is paging?

A

Paging divides memory into fixed-size blocks (pages).

Processes are stored in these equal-sized pages, enabling them to be loaded into any free memory frame.

Supports virtual memory because pages can be swapped in/out of secondary storage.

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

Benefits and drawbacks of paging

A

Benefits: Simple, allows non-contiguous memory, (non adjacent memory locations) supports virtual memory.

Drawbacks: Pages may not align with logical structures → inefficient. Page tables create overhead. (the resources, are consumed by the system to manage itself, rather than for performing the primary task)

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

What is segmentation?

A

Memory is divided into logical segments (e.g., code, stack, data).

Segments vary in size based on program structure.

More meaningful than paging because it reflects how programs are written.

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

What are the benefits of segmentation?

A

Segments are logical divisions → easier program organisation (e.g., code, stack, heap).

Segments can be sized exactly → reduces internal fragmentation.

Supports protection, as individual segments can have different access rights.

Allows for sharing of segments between processes (e.g., shared libraries).

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

What are the drawbacks of segmentation?

A

Causes external fragmentation because segments vary in size.

Harder for the OS to manage compared to fixed-size pages.

More complex memory allocation algorithms.

Moving segments around to defragment memory increases overhead.

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

What is internal fragmentation?

A

Internal fragmentation occurs when fixed-size memory blocks are allocated to a process, but the process doesn’t fully use the entire block, leaving unused space inside the allocated block.

This waste occurs most commonly when paging is used.

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

Why does internal fragmentation happen?

A

Because paging uses fixed-size pages/frames (e.g., 4 KB).

If a process needs memory that is not a perfect multiple of the page size, the last page is not fully used → wasted space.

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

Example of internal fragmentation

A

Process needs 10 KB, page size 4 KB → allocation needs 3 pages (12 KB).

Only 10 KB is used → 2 KB is wasted inside the last page.

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

Benefits of paging (despite internal fragmentation)

A

Very simple allocation (fixed-size blocks).

Eliminates external fragmentation.

Pages can be swapped in/out easily → supports virtual memory efficiently.

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

Drawbacks of internal fragmentation

A

Memory is wasted inside allocated pages.

More RAM is consumed → can force the OS to use virtual memory earlier → slower performance.

Particularly bad for many small processes.

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

What is external fragmentation?

A

External fragmentation occurs when free memory is split into many small non-contiguous blocks, so although the total free space is large, no single large block is available for a process that needs one.

Occurs most with segmentation (variable-sized blocks).

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

Why does external fragmentation happen?

A

Because segmentation allocates variable-sized memory segments.

As processes are loaded/unloaded, free gaps appear between segments → memory becomes “fragmented”.

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

Example of external fragmentation

A

Free memory: 20 MB total → blocks are: 8 MB + 6 MB + 6 MB.

A process needs 10 MB, but no single free block is ≥ 10 MB → allocation fails.

17
Q

Benefits of segmentation (despite external fragmentation)

A

Memory fits closer to program structure (code, stack, heap).

Allows variable-sized allocation → reduces internal waste.

Supports protection + sharing at the segment level.

18
Q

Drawbacks of external fragmentation

A

Free memory becomes unusable due to scattered gaps.

Requires compaction (expensive) to rearrange segments.

Slows allocation because OS must search for a block big enough.

Can eventually make RAM inefficiently utilised.

19
Q

Key difference between internal vs external fragmentation

A

Internal: Waste inside allocated blocks, caused by fixed-size pages.

External: Waste between allocated blocks, caused by variable-size segments.

20
Q

Paging vs Segmentation

A

Paging: Fixed size, physical division, simple but not logical.
Segmentation: Variable size, logical division, matches program structure.
OSs may use both.

21
Q

What is an Interrupt Service Routine (ISR)?

A

A predefined routine the CPU jumps to when an interrupt occurs.
Handles the event (e.g., read input, complete I/O, manage error).
Stored in interrupt vector table.

22
Q

What is an interrupt and how does an Interrupt Service Routine (ISR) work?

A

An interrupt is a signal that temporarily halts the CPU so an urgent event can be handled.

When triggered, the CPU finishes its current instruction, saves its state to the stack, and jumps to the appropriate ISR using the interrupt vector table.

The ISR handles the event (e.g., I/O, errors, timer), then the CPU restores the saved state and resumes the interrupted program.

This allows multitasking, efficient I/O, and rapid response to external/internal events.