What Is An Operating System (OS) AnswerAn Operating System
What Is An Operating System (OS) AnswerAn Operating System
Introduction to Linux
1. What is the Architecture of the Linux Operating System?
The Linux Operating System has a layered architecture, with each
layer interacting with the ones adjacent to it. The core of the Linux OS
is the kernel, which manages hardware resources, processes,
memory, and device drivers. Above the kernel are the system
libraries that provide functionalities like file manipulation and I/O
operations. System utilities provide additional functionalities such as
file management, user management, and system monitoring tools.
The top layer consists of user applications, including desktop
environments, command-line tools, and software applications.
Vi Editor
Unit – 1
1. Explain multiprogramming ,time sharing, distributed
system and real time system in terms of memory
management, process management and processor
scheduling.
1. Multi-programming Systems
Memory Management:
Process Management:
Processor Scheduling:
2. Time-Sharing Systems
Memory Management:
Time-sharing systems allow multiple users to interact with the system
simultaneously, each getting a time slice of the CPU. The OS uses
techniques like virtual memory, where processes are given the illusion of
having more memory than what is physically available. This is achieved by
swapping data between the main memory and the disk. Each user’s
program is loaded into memory using paging or segmentation, and the
system manages memory allocation efficiently to avoid overlap between
users.
Process Management:
Processor Scheduling:
3. Distributed Systems
Memory Management:
Process Management:
Processor Scheduling:
4. Real-Time Systems
Memory Management:
Process Management:
Process management in real-time systems is focused on ensuring that
processes meet their strict deadlines. Processes are prioritized based on
their urgency, with higher-priority processes preempting lower-priority
ones. The OS must ensure that critical tasks are completed within their
time constraints, often using techniques like priority inheritance to prevent
priority inversion (where a lower-priority process holds up a higher-priority
one). The OS handles periodic tasks (tasks that must run at regular
intervals) and aperiodic tasks (tasks triggered by specific events).
Processor Scheduling:
Summary
Syste Processor
Memory Management Process Management
m Scheduling
Multi-
Segmentation, paging, Manages concurrent CPU scheduling to
progra
swapping to load processes using maximize utilization
mmin
multiple processes. context switching. (e.g., FCFS, RR).
g
Time- Virtual memory, paging, Manages multiple user Round Robin
sharin efficient memory processes, ensuring scheduling for equal
g allocation. fairness. CPU time slices.
Processes distributed Local and global
Distrib Decentralized memory,
across nodes, IPC for scheduling, load
uted DSM for shared access.
communication. balancing.
Physical memory, Manages time-critical Scheduling based on
Real-
deterministic access, processes, priority- deadlines, using RMS
time
avoids virtual memory. based. or EDF.
How it works:
Linux Architecture
1. Hardware Layer:
2. This is the lowest level of the architecture, consisting of
physical hardware components like CPU, memory, storage
devices, input/output devices, etc. The Linux kernel interacts
directly with the hardware through device drivers.
3. Kernel Layer:
+------------------------------------+
| User Applications |
+------------------------------------+
|
+------------------------------------+
| Shell |
+------------------------------------+
|
+------------------------------------+
| Kernel |
+------------------------------------+
| Process | Memory | Device | File |
| Management | Management | Mgmt. |
+------------------------------------+
|
+------------------------------------+
| Hardware |
+------------------------------------+
Basic Directory Structure of Linux
1. / (Root Directory):
The root directory is the base of the Linux file system. All other
files and directories are contained within /.
2. /bin (Binaries):
3. /boot:
7. /lib (Libraries):
8. /media:
9. /mnt:
10. /opt:
11. /proc:
12. /root:
This is the home directory of the root user (superuser). It is
different from / which is the root of the entire file system.
Stores variable data like logs, mail spools, print queues, and
temporary files that are generated by system services and
applications. For instance, /var/log contains system log files.
/ (root)
|
|-- /bin
|-- /boot
|-- /dev
|-- /etc
|-- /home
| |-- user1
| |-- user2
|-- /lib
|-- /media
|-- /mnt
|-- /opt
|-- /proc
|-- /root
|-- /sbin
|-- /tmp
|-- /usr
| |-- bin
| |-- lib
| |-- share
|-- /var
|-- log
|-- mail
Description:
Syntax:
Common Usage:
$ cat file.txt
This is the content of the file.
Description:
Syntax:
mv [source] [destination]
Common Usage:
Example Output:
$ mv test.txt /home/user/docs/
$ ls /home/user/docs/
test.txt
c. who (Show Who is Logged On)
Description:
Syntax:
who [options]
Common Usage:
Example Output:
$ who
user1 pts/0 2024-10-11 12:34
user2 pts/1 2024-10-11 13:20
Description:
pwd prints the current working directory, showing the full path to
where the user is located in the filesystem.
Syntax:
pwd
Common Usage:
Show the current working directory:pwd
Example Output:
$ pwd
/home/user/documents
Description:
Syntax:
tty
Common Usage:
Example Output:
$ tty
/dev/pts/0
f. apropos (Search for Commands by Description)
Description:
Syntax:
apropos [keyword]
Common Usage:
Example Output:
$ apropos network
ifconfig (8) - configure a network interface
ping (8) - send ICMP ECHO_REQUEST to
network hosts
netstat (8) - print network connections,
routing tables, interface statistics, etc.
Comma
Function
nd
cat Displays, concatenates, or creates files.
mv Moves or renames files or directories.
Shows who is currently logged into the
who
system.
pwd Prints the current working directory.
Displays the terminal or pseudo-terminal
tty
in use.
Searches manual pages for commands
apropos
by description.
Unit – 2
1. What is process synchronisation ? explain how
reader-writer problem can be solved using semaphore
with the help of pseudocode.
// Reader Process
Reader() {
wait(mutex); // Lock the mutex to update readcount
readcount++; // Increment the number of readers
if (readcount == 1) // If this is the first reader
wait(wrt); // Lock the shared resource from writers
signal(mutex); // Release the mutex
// Writer Process
Writer() {
wait(wrt); // Lock the shared resource (exclusive
access)
Explanation
1. Reader Process:
a. A reader locks the mutex to safely increment the
readcount.
b. If the readcount becomes 1 (first reader), it locks wrt
to prevent any writer from accessing the shared
resource.
c. After reading, the reader locks the mutex again to
decrement the readcount.
d. If the readcount becomes 0 (last reader), it unlocks
wrt to allow writers to access the shared resource.
2. Writer Process:
a. A writer locks the wrt semaphore to get exclusive
access to the shared resource.
b. After writing, it releases wrt so other writers or readers
can access the resource.
p1 0 3
p2 1 2
p3 3 6
p4 4 5
p5 5 3
Copy code
| P1 | P2 | P3 | P4 | P5 |
0 3 5 11 16 19
P1: 3 - 0 = 3
P2: 5 - 1 = 4
P3: 11 - 3 = 8
P4: 16 - 4 = 12
P5: 19 - 5 = 14
P1: 3 - 3 = 0
P2: 4 - 2 = 2
P3: 8 - 6 = 2
P4: 12 - 5 = 7
P5: 14 - 3 = 11
Selects the process with the shortest burst time next (only once
a process is ready to execute).
Copy code
| P1 | P2 | P5 | P4 | P3 |
0 3 5 8 13 19
P1: 3 - 0 = 3
P2: 5 - 1 = 4
P3: 19 - 3 = 16
P4: 13 - 4 = 9
P5: 8 - 5 = 3
Average TAT = (3 + 4 + 16 + 9 + 3) / 5 = 7 ms
P1: 3 - 3 = 0
P2: 4 - 2 = 2
P3: 16 - 6 = 10
P4: 9 - 5 = 4
P5: 3 - 3 = 0
Average WT = (0 + 2 + 10 + 4 + 0) / 5 = 3.2 ms
3. Shortest Remaining Time Next (SRTN) - Preemptive
SJF
go
Copy code
| P1 | P2 | P3 | P4 | P5 |
0 3 5 7 11 19
3.a. what is critical section problem? how it can be solved
using semaphore.
b. explain the linux command to view currently running
process on the system. explain nice and renice command in
linux with exmaple
c. explain three different types of schedulers in operating
system with the help of neat diagram, explain specific role of
each type of scheduler.
3a. What is the Critical Section Problem? How can it be solved using
Semaphore?
Process 1:
wait(S);
// Critical Section
signal(S);
Process 2:
wait(S);
// Critical Section
signal(S);
Explanation:
o The semaphore ensures that only one process enters
the critical section at a time.
o If one process is in the critical section, other processes
are blocked until the semaphore is released (using
signal()).
Command: ps
o Shows information about active processes.
o Example:
bash
Copy code
ps -aux
2. nice Command:
3. Medium-Term Scheduler
Diagram of Schedulers in OS
plaintext
Copy code
+---------------------+
| New Processes |
+---------------------+
|
v
+--------------------+
| Long-Term Scheduler |
+--------------------+
|
v
+--------------------+
| Ready Queue |
+--------------------+
|
v
+--------------------+
| Short-Term Scheduler (CPU Scheduler) |
+--------------------+
|
v
+---------------------+
| Running Process |
+---------------------+
^
| (Swapping)
+--------------------+
| Medium-Term Scheduler |
+--------------------+
Summary of Roles:
2. Automotive Industry
3. Telecommunications
4. Medical Devices
5. Industrial Automation
6. Consumer Electronics
Long-Term Short-Term
Feature Medium-Term Scheduler
Scheduler Scheduler
Primary Degree of Manage memory and
CPU Allocation
Focus Multiprogramming process load
Execution Infrequently Occasionally (when Very Frequently
Frequency (minutes) memory overloaded) (milliseconds)
Loads processes Swaps processes in/out of Selects process for
Function
into memory memory CPU
Ensure balanced Maximize CPU
Goal Avoid memory bottlenecks
workloads usage
Example Batch jobs Swapping inactive Round Robin
Usage admission processes scheduling
Summary