0% found this document useful (0 votes)
8 views12 pages

Operating System Notes

The document outlines key concepts in operating systems, including data access control, program isolation, user authentication, and resource management. It discusses how processes interact with the CPU and memory, emphasizing the importance of CPU scheduling for efficient operation in multiprogramming environments. Additionally, it explains multilevel queue scheduling, highlighting the use of different queues for managing processes based on priority and type.

Uploaded by

238w1a0519
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views12 pages

Operating System Notes

The document outlines key concepts in operating systems, including data access control, program isolation, user authentication, and resource management. It discusses how processes interact with the CPU and memory, emphasizing the importance of CPU scheduling for efficient operation in multiprogramming environments. Additionally, it explains multilevel queue scheduling, highlighting the use of different queues for managing processes based on priority and type.

Uploaded by

238w1a0519
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

OS NOTES

Data Access Control


In systems where many users work together, the owners of information want to
control who can access or modify their data.

Program Isolation
When different programs (or processes) run at the same time, none of them should be
able to interfere with each other—or with the operating system itself.

Controlled Resource Access


The operating system makes sure that all access to files, memory, devices, and other
resources is done safely and only by those who have permission.

User Authentication
To prevent outsiders from using the system, each user must prove who they are—
usually by entering a valid username and password.

Device Security
The system also protects hardware like USB ports and network connections from
unauthorized access or attacks.

Monitoring Access
The system keeps records (logs) of who connects to it and what they do. This helps
detect intruders or break-in attempts.

End-to-End Security
For the system to be truly secure, every part of it—from login to file access to device
communication—must be protected. One weak spot can break the whole chain.

An API tells the programmer what they can do, what info they need to give, and what
they’ll get back. It’s like following steps to ask for something and knowing exactly
what to expect.

A programmer uses an API through special code libraries that the operating system
gives them. These libraries contain functions that act like helpers—they talk to the
operating system behind the scenes so the programmer doesn’t have to do it directly.

When a program wants to use a system call (like reading a file or creating a process),
it often needs to send extra information—like which file to read or what data to write.
But how does it send that info to the operating system?

There are three main ways to pass this information (parameters):


1.

Registers – Fastest method. Parameters are placed directly into CPU registers.

2.
1. ✅ Simple and quick.
2. ❌ Limited by the number of available registers.
3.

Memory Block/Table – Parameters are stored in a memory block, and the


address of that block is passed in a register.

4.

1. ✅ Used by Linux and Solaris.


2. ✅ Can handle many or large parameters.
3. ❌ Slightly more complex.

5.

Stack – Parameters are pushed onto the program’s stack and popped off by the
OS.

6.

1. ✅ Flexible and doesn’t limit parameter size.


2. ✅ Often used in older or simpler systems.

Real-World Application Example: write() System Call in Linux

Let’s say you’re writing a program that prints “Hello, Hasini!” to the terminal.

You might use the write() system call like this in C:

write(1, "Hello, Hasini!\n", 15);

Here’s how the parameters are passed:

 1 → file descriptor (stdout)


 "Hello, Hasini!\n" → pointer to the message
 15 → number of bytes to write

How Linux Handles It:

 These three values are placed in registers (if there’s room).


 If there are more parameters than registers, Linux may:

o Store them in a memory block and pass the block’s address.


o Or use the stack to push them temporarily.
This flexibility allows Linux to support complex system calls without being limited
by hardware constraints.

In computing, a process represents a running instance of a program, including the


program's code and the current state of its execution.

A process's memory is typically organized into four main segments:

 🧠 Text segment: Holds the executable code of the program, which is loaded from non-
volatile storage (like a hard drive or SSD) when the program starts running. This section is
usually read-only.
 📊 Data segment: Contains global and static variables that are defined and initialized before
entering the main() function.
 📦 Heap segment: Used for dynamic memory allocation during runtime. It grows as needed
and is managed using commands such as new, delete, malloc, and free.
 🌀 Stack segment: Stores local variables and function call information. Space is allocated when
functions are entered and deallocated when variables go out of scope.

🧮 CPU Registers
These are small, super-fast memory units inside the CPU. They come in different
types depending on the system architecture and include:

 Accumulators – store intermediate results during calculations


 Stack Pointers – track the top of the stack for managing function calls
 General Purpose Registers – used for temporary storage and operations

CPU Scheduling Information


This helps the operating system manage which process should run next. It includes:

 Process Priority – how important the process is


 Pointers to Scheduling Queues – links to where the process is lined up
 Scheduling Parameters – rules that affect how and when it runs

Let me know if you'd like to explore how registers interact with memory or how
scheduling algorithms make decisions—I think you'd find it pretty fascinating!

🧠 Memory Management Information


This refers to the data a process holds to manage its memory usage efficiently and
safely. It includes:

 🧷 Base and Limit Registers


These specify the starting point and the maximum boundary of a process’s memory. They
help ensure the process accesses only its allotted memory—providing protection from illegal
access.
 📋 Page Tables
These are used in systems that implement paging. They act as a map that translates virtual
addresses used by the process into physical memory locations.
 🧩 Segment Tables
In systems using segmentation, these tables divide memory into distinct sections like code,
stack, or data. Each section is described by a base address and a size limit, providing both
structure and access control.
The primary goals of a process scheduling system are:

 To ensure the CPU remains actively utilized at all times


 To provide satisfactory response times, especially for interactive programs that require quick
feedback

To achieve these, the process scheduler applies well-designed policies that control
how processes are swapped in and out of the CPU, maintaining a balance between
efficiency and responsiveness.

Let me know if you want to see how different scheduling algorithms try to hit these
goals—like Round Robin vs. Priority Scheduling. I think you'd enjoy analyzing their
trade-offs!

When a process creates a child process, the child needs things like CPU time,
memory, files, and input/output devices to do its job. These can come directly from
the operating system or be given by the parent process. Sometimes, the parent divides
its own resources between its children or allows them to share. Limiting how much a
child can use helps prevent the system from getting overloaded. The parent can also
give the child some starting data to help it begin its work.

In some cases, a child process doesn't just continue the same program as its parent—it
can load and run a completely new program.

 In Windows, this is done using spawn system calls, which create the child process and load
the new program all in one step.
 In UNIX-like systems, this usually happens in two steps:

1. The parent uses fork() to create a child that's an exact copy of itself.
2. Then, the child uses exec() to replace itself with a new program.

This approach allows flexibility: UNIX can create a child process first, then decide
what it should run.
UNIT II

CPU SCHEDULING

In a multiprogramming operating system, the computer can keep several programs


(called processes) in memory at the same time. These processes take turns using the
CPU, which is made possible through a technique called process scheduling.

Each process doesn’t always need the CPU—sometimes it’s waiting for input or
output (like reading from a file or printing something). In older systems like MS-DOS
(which only ran one program at a time), the CPU would just sit idle while the process
waited for I/O. That’s wasted time.

But in a multiprogramming system, when one process is waiting for I/O, the CPU can
switch to another process that’s ready to run. This way, the CPU is always doing
something useful, and the system runs more efficiently.

Real-Time Analogy: A Restaurant Kitchen

Imagine a restaurant with one chef (the CPU) and several dishes (processes) to
prepare.

Uniprogramming (like MS-DOS):

 The chef starts cooking Dish A.


 Dish A needs to be baked for 20 minutes (I/O time).
 The chef just waits around doing nothing until the oven is done.
 Total waste of time!

Multiprogramming with Process Scheduling:

 The chef starts Dish A and puts it in the oven.


 Instead of waiting, the chef starts working on Dish B.
 When Dish A is done baking, the chef switches back to finish it.
 The chef is always busy, and more dishes get done faster.

That’s exactly how a multiprogramming OS works—it keeps the CPU (chef) busy by
switching between processes (dishes) whenever one is waiting for I/O (baking).

Key Insight: Process scheduling is like a smart kitchen manager—it keeps


the chef (CPU) working efficiently by juggling multiple dishes (processes) so that
no time is wasted.

The effectiveness of CPU scheduling relies on a key characteristic of processes:


 A process typically goes through a repeating cycle of using the CPU and waiting for I/O
operations.
 Execution starts with a CPU burst, where the process performs computations.
 This is followed by an I/O burst, during which the process waits for input/output to
complete.
 The cycle continues—alternating between CPU and I/O bursts—throughout the process's
lifetime.
 Eventually, the process reaches its final CPU burst, after which it makes a system call to
terminate.
 While they can vary significantly between different processes and systems, their overall
pattern tends to follow a frequency distribution like the one shown in Figure 5.2.

 This distribution is typically exponential or hyper-exponential, meaning that most CPU


bursts are short, while only a few are long.
 I/O-bound programs usually generate many short CPU bursts because they frequently wait
for I/O operations.
 In contrast, CPU-bound programs tend to have fewer but longer CPU bursts, as they spend
more time performing computations.
 Understanding this distribution is crucial when designing and implementing effective CPU
scheduling algorithms.

This algorithm estimates the duration of each process’s upcoming CPU usage and
uses that information for scheduling decisions.

Rephrased Explanation

When different types of processes can be grouped easily—like short tasks, long tasks,
or real-time tasks—we can create separate queues for each group. Each queue can
use its own scheduling method that best suits the type of jobs it holds.

But since there are multiple queues, the system also needs to decide which queue
gets the CPU and when. This is called scheduling between queues.

There are two common ways to do this:

Strict Priority

1. Queues are ranked by importance.


2. The CPU always serves the highest-priority queue first.
3. Lower-priority queues only get CPU time when all higher ones are empty.

Round-Robin Between Queues

1. Each queue gets a turn to use the CPU.


2. The time given to each queue can be equal or different depending on the system’s
needs.

Also, in this setup, once a job is placed in a queue, it stays there until it finishes. It
doesn’t move between queues.
Real-Life Example: Airport Check-In Counters

Imagine an airport with three check-in counters (queues):

 Counter 1: First-class passengers (high priority)


 Counter 2: Business class
 Counter 3: Economy class (low priority)

Each counter has its own way of handling passengers:

 Counter 1 is super fast and efficient.


 Counter 2 uses a balanced method.
 Counter 3 takes longer because of more people.

Now, the airport must decide how to serve these counters:

 Strict Priority: First-class passengers are always served first. Economy passengers wait until
all first-class and business passengers are done.
 Round-Robin: Each counter gets a turn. Maybe Counter 1 gets 2 minutes, Counter 2 gets 3
minutes, and Counter 3 gets 5 minutes.

Once a passenger is assigned to a counter, they stay there—they don’t switch to


another counter.

Absolutely, Hasini! Here's a rephrased and explained version of each point from your
notes on Multilevel Queue Scheduling, with real-world analogies and applications to
make it easier to grasp:

🔹 1. Single Queue with Priority or Round-Robin

Original:
With both priority and round-robin scheduling, all processes may be placed in a single
queue, and the scheduler then selects the process with the highest priority to run.

Rephrased & Explained:


In basic scheduling, all processes are kept in one big line (queue), and the CPU picks
the one with the highest priority to run next. If multiple processes have the same
priority, they take turns using the CPU (round-robin style).

Application: This is like a helpdesk where urgent tickets are handled first, and
equally urgent ones are handled in turns.

🔹 2. O(n) Search for Highest Priority


Original:
Depending on how the queues are managed, an O(n) search may be necessary to
determine the highest-priority process.

Rephrased & Explained:


If all processes are in one list, the system might have to check each one to find the
highest priority, which takes time—especially if there are many processes.

🧠 Application: Like scanning a long to-do list to find the most urgent task—it slows
things down.

🔹 3. Separate Queues for Each Priority

Original:
In practice, it is often easier to have separate queues for each distinct priority, and
priority scheduling simply schedules the process in the highest-priority queue.

Rephrased & Explained:


To make things faster, we can create different queues for different priority levels. The
CPU always picks a process from the highest-priority queue that has tasks waiting.

📊 Application: Like having separate checkout lines for VIP, regular, and express
customers—VIPs are always served first.

🔹 4. What Is Multilevel Queue Scheduling?

Original:
This approach is known as multilevel queue.

Rephrased & Explained:


This method of using multiple queues based on priority or process type is called
multilevel queue scheduling.

🔹 5. Combining Priority and Round-Robin

Original:
Multilevel queue also works well when priority scheduling is combined with round-
robin: if there are multiple processes in the highest-priority queue, they are executed
in round-robin order.

Rephrased & Explained:


If several processes are in the same high-priority queue, they take turns using the CPU
(round-robin), but only after all lower-priority queues are ignored.
🎮 Application: In a multiplayer game server, premium users (high priority) take turns
playing before free users get a chance.

🔹 6. Static Priority Assignment

Original:
In the most generalized form of this approach, a priority is assigned statically to each
process, and a process remains in the same queue for the duration of its runtime.

Rephrased & Explained:


Each process is given a fixed priority when it starts, and it stays in the same queue
until it finishes. It doesn’t move between queues.

📌 Application: Like assigning a student to a class section at the start of the semester
—they stay in that section until the course ends.

🔹 7. Queues Based on Process Type

Original:
A multilevel queue scheduling algorithm can also be used to partition processes into
several separate queues based on the process type.

Rephrased & Explained:


Instead of just using priority, we can also group processes by type—like interactive
tasks vs. background tasks—and put them in different queues.

Application: Your computer might separate real-time video calls (interactive) from
file downloads (background).

🔹 8. Foreground vs. Background Queues

Original:
A common division is made between foreground (interactive) processes and
background (batch) processes.

Rephrased & Explained:


A typical setup is to have one queue for tasks that need quick responses (like user
apps) and another for tasks that can run quietly in the background (like backups).

🔹 9. Different Scheduling for Each Queue


Original:
These two types of processes have different response-time requirements and so may
have different scheduling needs.

Rephrased & Explained:


Since interactive and background tasks behave differently, each queue can use a
different scheduling method that suits its needs.

🔹 10. Foreground May Have Higher Priority

Original:
Foreground processes may have priority (externally defined) over background
processes.

Rephrased & Explained:


Interactive tasks often get higher priority than background ones, so they can respond
faster to user actions.

📱 Application: When you open an app, your phone pauses background updates to
make the app load quickly.

🔹 11. Different Algorithms per Queue

Original:
The foreground queue might be scheduled by an RR algorithm, for example, while the
background queue is scheduled by an FCFS algorithm.

Rephrased & Explained:


Each queue can use its own scheduling rule. For example, interactive tasks might take
turns (Round Robin), while background tasks are handled in the order they arrive
(First-Come, First-Served).

🔹 12. Scheduling Between Queues

Original:
There must be scheduling among the queues, which is commonly implemented as
fixed-priority preemptive scheduling.

Rephrased & Explained:


The system also needs to decide which queue gets the CPU. A common method is
fixed-priority preemptive scheduling, where higher-priority queues can interrupt
lower ones.
🔹 13. Example: Four Queues by Priority

Original:
A multilevel queue scheduling algorithm with four queues:

1. Real-time processes
2. System processes
3. Interactive processes
4. Batch processes

Rephrased & Explained:


Here’s a typical setup with four queues, ranked from highest to lowest priority:

1. Real-time tasks (e.g., emergency alerts)


2. System tasks (e.g., OS updates)
3. User apps (e.g., browsers, editors)
4. Background jobs (e.g., backups)

🔹 14. Absolute Priority Between Queues

Original:
Each queue has absolute priority over lower-priority queues.

Rephrased & Explained:


A queue can only run if all higher-priority queues are empty.

🔹 15. Preemption Example

Original:
If an interactive process entered the ready queue while a batch process was running,
the batch process would be preempted.

Rephrased & Explained:


If a user app becomes ready while a background task is running, the background task
is paused so the user app can run.

🔹 16. Time-Slicing Between Queues

Original:
Another possibility is to time-slice among the queues. Each queue gets a certain
portion of the CPU time.
Rephrased & Explained:
Instead of strict priority, the system can give each queue a turn to use the CPU for a
set amount of time. This helps prevent lower-priority queues from starving.

🧠 Application: Like giving each department in a company a fixed time slot to use a
shared meeting room.

You might also like