Professional Documents
Culture Documents
st20270256 PORT1 CMP4011
st20270256 PORT1 CMP4011
1011010001
2D1
10101000001
541
11001010100
654
10100111011
53B
2. A monolithic system OS is where the whole OS operates solely within the kernel space,
meaning file, memory, process, and device management all take place within the kernel
space. This means it is very limited in its modularity, meaning adding anything to it would
require many changes to be done to other parts of it, same with any updates. It would
however, have very good performance as it is all one code, same for memory, as it would
not use very much.
A layered OS would mean that user and system operations are separated, with user software
operations being handled at the top layers, and system layers at the bottom. This, while making it so
that performance may be a bit worse due to inter-layer communication and would require more
memory, means that new features can be easily added as the system is already programmed in a
modular manner, with any updates and such being easily integrated. This also means that security
would be tighter as each layer is isolated, meaning the system is safer.
4. Kernel controls the communication between hardware and software, it has direct access to
the CPU, disk, and RAM. It is responsible for device drivers, security, memory management
and process scheduling.
The shell on the other hand is a user interface for interacting with the OS. It has restricted
access to hardware resources and relies on the kernel to perform the operations. The user
can, through the shell, execute commands, manipulate files, and run programs.
5. Here’s the program:
#include <iostream>
#include <ctime>
#include <cstdlib>
int main() {
int arr[100];
fillArray(arr);
printArray(arr, 100);
int* p = arr;
std::cout << "Address of array arr = " << p << std::endl;
return 0;
}
Priority:
P2: Turnaround Time = 2, Waiting Time = 0
P1: Turnaround Time = 6, Waiting Time = 2
P4: Turnaround Time = 14, Waiting Time = 6
P5: Turnaround Time = 24, Waiting Time = 14
P3: Turnaround Time = 40, Waiting Time = 24
7. A. The maximum number of "C"s printed is 3, occurring when Process A runs three times.
B. Process B can run twice, printing "B" each time, before semaphore V becomes 0. So, the
maximum number of "B"s printed is 2.
C. Similarly, Process C can run twice, printing "D" each time, before semaphore W becomes
0. So, the maximum number of "D"s printed is 2.
9. LRU -
Page 1: [1], Page Fault = 1
Page 2: [1, 2], Page Fault = 2
Page 3: [1, 2, 3], Page Fault = 3
Page 4: [4, 2, 3], Page Fault = 4
Page 2: [4, 2, 3], Page Fault = 4
Page 1: [1, 4, 3], Page Fault = 5
Page 5: [5, 4, 3], Page Fault = 6
Page 6: [6, 4, 3], Page Fault = 7
Page 2: [6, 4, 2], Page Fault = 8
Page 1: [1, 4, 2], Page Fault = 9
Page 2: [1, 2, 4], Page Fault = 10
Page 3: [3, 1, 2], Page Fault = 11
Page 7: [7, 1, 2], Page Fault = 12
Page 6: [7, 1, 6], Page Fault = 13
Page 3: [7, 3, 6], Page Fault = 14
Page 2: [7, 3, 2], Page Fault = 15
Page 1: [1, 3, 2], Page Fault = 16
Page 2: [1, 3, 2], Page Fault = 16
Page 3: [1, 3, 2], Page Fault = 16
Page 6: [6, 3, 2], Page Fault = 17
FIFO –
Page 1: [1], Page Fault = 1
Page 2: [1, 2], Page Fault = 2
Page 3: [1, 2, 3], Page Fault = 3
Page 4: [2, 3, 4], Page Fault = 4
Page 2: [3, 4, 2], Page Fault = 5
Page 1: [4, 2, 1], Page Fault = 6
Page 5: [2, 1, 5], Page Fault = 7
Page 6: [1, 5, 6], Page Fault = 8
Page 2: [5, 6, 2], Page Fault = 9
Page 1: [6, 2, 1], Page Fault = 10
Page 2: [2, 1, 2], Page Fault = 11
Page 3: [1, 2, 3], Page Fault = 12
Page 7: [2, 3, 7], Page Fault = 13
Page 6: [3, 7, 6], Page Fault = 14
Page 3: [7, 6, 3], Page Fault = 15
Page 2: [6, 3, 2], Page Fault = 16
Page 1: [3, 2, 1], Page Fault = 17
Page 2: [2, 1, 2], Page Fault = 18
Page 3: [1, 2, 3], Page Fault = 19
Page 6: [2, 3, 6], Page Fault = 20
Optimal –
Page 1: [1], Page Fault = 1
Page 2: [1, 2], Page Fault = 2
Page 3: [1, 2, 3], Page Fault = 3
Page 4: [1, 2, 3], Page Fault = 3
Page 2: [1, 2, 3], Page Fault = 3
Page 1: [1, 2, 3], Page Fault = 3
Page 5: [5, 2, 3], Page Fault = 4
Page 6: [5, 6, 3], Page Fault = 5
Page 2: [5, 6, 2], Page Fault = 6
Page 1: [5, 6, 2], Page Fault = 6
Page 2: [5, 6, 2], Page Fault = 6
Page 3: [5, 6, 3], Page Fault = 7
Page 7: [5, 6, 7], Page Fault = 8
Page 6: [5, 6, 7], Page Fault = 8
Page 3: [5, 6, 7], Page Fault = 8
Page 2: [5, 6, 7], Page Fault = 8
Page 1: [5, 6, 7], Page Fault = 8
Page 2: [5, 6, 7], Page Fault = 8
Page 3: [5, 6, 7], Page Fault = 8
Page 6: [5, 6, 7], Page Fault = 8
10. First-Fit:
P1: Block2
P2: Block5
P3: Block3
P4: Block1
P5: Block1
Best-Fit:
P1: Block2
P2: Block5
P3: Block4
P4: Block1
P5: Block4
Worst-Fit:
P1: Block2
P2: Block5
P3: Block4
P4: Block1
P5: Block4
11. Windows and Linux are different in many aspects such as:
Kernel Architecture – Linux is monolithic, where all services run in the same space, with
device drivers and core system services making part of it. In Windows, both monolithic and
microkernel are used. Core services such as process and memory management run in kernel,
while device drivers and subsystems run in user mode.
UI –
Linux usually uses a GUI, but it can also be just text based. The default shell is BASH.
Windows on the other hand has a GUI mainly – start menu and such, with the CMD and PS
for shell.
File System –
Linux uses system files such as ext4, xfs and btrfs, using the FHS hierarchy. Windows on the
other hand uses NTFS, with FAT32 and exFAT also being supported.
Process Management –
Linux follows a multi-process, multi-threaded model where processes can use multiple
threads. It has a priority based scheduling algorithm for management, similarly to Windows.
Memory Management –
Linux has virtual memory management, with support for demand paging, memory mapping
and shared memory, using techniques such as copy-on-write and memory overcommitment.
Windows also uses these techniques but includes AWE for large memory support.
Security –
Linux follows DAC (Discretionary Access Control) where the owner controls all. Windows
uses both DAC and MAC (Mandatory Access Control) through its Security Descriptor
Definition Language (SDDL) and control lists (ACLs).
Device/Driver Management –
Linux has a modular driver model, where drivers are loaded into modules into the kernel at
runtime. Devices are managed through the /dev directory. Windows uses a layered driver
model, with the drivers being classified into kernel and user mode drivers. Device
management is done through the Device Manager and Registry.
Open/Closed Source –
Linux is fully open source, which is why there are many different distros, whilst Windows is
fully proprietary, with different versions being produced by Microsoft itself.