Bit2104 Cat 2
Bit2104 Cat 2
Bit2104 Cat 2
BIT/2022/51475
In memory management, different memory allocation strategies are used to efficiently manage
Static Allocation: Memory is allocated at compile time and the allocation size is fixed.
Dynamic Allocation: Memory is allocated during runtime as needed, allowing for more
manner. Used for managing function call frames, local variables, and temporary data.
Heap Allocation: Memory is allocated from a large pool (heap) and can be dynamically
Static Allocation is fast and simple but inflexible, making it suitable for
applications with varying memory needs but comes with runtime overhead and
potential fragmentation.
variables.
Heap Allocation is more flexible and supports dynamic data structures but can
suffer from fragmentation and has higher overhead due to the need for managing
divides the program into logical segments and the benefits it offers in terms of
Segmentation is a memory management technique that divides the program’s memory into
distinct segments based on logical units or segments, such as functions, arrays, or data structures.
Each segment has a different role and size, allowing for more organized and efficient memory
use.
Logical Segments: In segmentation, a program is divided into logical segments that reflect the
information such as the segment's base address, size, and access permissions.
Benefits of Segmentation
Modularity: Segmentation allows for organizing code and data into logical units,
which can improve program clarity and maintainability. Each segment can be
structure.
Access Control: Each segment can have different access permissions (e.g., read,
write, execute). This helps protect segments from unauthorized access and
Isolation: Segments are protected from each other, reducing the risk of one
segment corrupting another. For example, a bug in the code segment does not
c) Compare and contrast counting semaphores and binary semaphores. Identify their
environment? (2 Marks)
Characteristics
Range: Can have a non-negative integer value, which can be greater than 1.
Purpose: Used to control access to a resource pool with multiple instances. The
Usage Scenarios
Binary Semaphores:
Characteristics:
occupied.
Mutual Exclusion: Suitable for ensuring that only one process or thread can
state changes.
Differences in Implementation:
Counting Semaphores: The value of the semaphore can be incremented and decremented,
Binary Semaphores: The value is either 0 or 1, with operations to set and clear the
semaphore. This makes them simpler to implement but less flexible than counting
semaphores.
Influence on Scheduling:
Process Priority: Semaphore operations can affect process priority by controlling
synchronization requirements.
resources, influencing which processes can access resources and when, impacting
In Multi-Programming Environments:
Concurrency Control: Semaphores ensure that multiple processes or threads can safely
and efficiently access shared resources, preventing conflicts and ensuring proper
synchronization.
Deadlock Prevention: Proper use of semaphores can help prevent deadlocks by ensuring
that processes do not indefinitely wait for resources held by each other.
(2 Marks)
Multi-Threading: Multi-threading involves breaking down a process into multiple threads, each
of which can run concurrently. Threads share the same process resources but execute different
CPUs and memory) to run multiple operating systems or instances on a single physical machine.
Containers: Containers are lightweight, portable units that package an application ants
o .
(1 mark)
Types of Interrupts
Hardware Interrupts: Generated by hardware devices to signal the CPU about events that
Software Interrupts: Initiated by software instructions to request system services from the
operating system.
Mask able Interrupts: Can be ignored or "masked" by setting certain bits in a control
register.
Non-Mask able Interrupts (NMI): Cannot be ignored and must be processed immediately.
processors.
Interrupts allow hardware devices to communicate with the CPU without the need for continuous
polling. When a hardware device needs the CPU's attention, it sends an interrupt signal. This
mechanism ensures efficient and timely processing of events, reducing CPU idle time and
Interrupt Generation:
A program requests data from a disk drive. The CPU issues a read command to
Interrupt Signal:
Once the disk drive has completed reading the requested data, it sends a hardware
Interrupt Handling:
The CPU, upon receiving the interrupt signal, pauses its current operations and
Data Transfer:
The ISR retrieves the data from the disk controller and transfers it to the
The ISR may also update the status of the I/O operation, signaling the requesting
Resuming Operation:
After handling the interrupt, the CPU restores the state of the previously running
and variable partitions differ in their approach to managing memory? Discuss the
Memory management is a crucial function of an operating system (OS) that involves the
allocation, management, and optimization of computer memory. It ensures that each process has
enough memory to execute efficiently and that system memory is utilized optimally. Memory
management also involves the protection of memory space to prevent processes from interfering
Protection: Ensuring that processes do not interfere with each other's memory spaces.
Segmentation: Dividing memory into segments based on the logical division of programs.
Paging: Dividing memory into fixed-size pages to manage it more efficiently and to
Memory Utilization:
fragmentation. Large partitions may have unused space if processes do not need
Flexibility:
Fixed Partitioning: Inflexible, as partition sizes are static and do not adapt to
processes at runtime.
Complexity:
allocation.
Fragmentation:
sizes.
becomes scattered.
Fixed Partitioning: Limits process size to the maximum partition size, potentially