Lecture No. 05
Dated: 28-04-2025
Browsing UNIX
/ Linux
Directory Structure
Displaying Directory Contents
By default, the ls
commands takes .
as input.
mzaid@MZaid:/mnt/g/Projects/ChuzaWick420$ ls
README.md assets
mzaid@MZaid:/mnt/g/Projects/ChuzaWick420$ ls -a
. .. .git README.md assets
mzaid@MZaid:/mnt/g/Projects/ChuzaWick420$ ls -la
total 4
drwxrwxrwx 1 mzaid mzaid 512 Apr 17 18:12 .
drwxrwxrwx 1 mzaid mzaid 512 Apr 20 20:46 ..
drwxrwxrwx 1 mzaid mzaid 512 Apr 17 18:13 .git
-rwxrwxrwx 1 mzaid mzaid 2848 Apr 17 18:12 README.md
drwxrwxrwx 1 mzaid mzaid 512 Nov 20 14:10 assets
The columns represent the following
- Entry type (
d
for directory and-
for file) alongside permissions. - Number of hard links
- Owner name
- Group of the owner
- Size in bytes
- Month of last modification
- Day of last modification
- Time of last modification
- Entry name
The files starting with .
are called dot files
or hidden files
.
Creating Directories
mkdir directory name
Deleting Directories
rmdir directory name
Changing Directories
cd directory name
Display Absolute Path of Your Working Directory
pwd
Copying Files
cp file_to_copy destination
Examples
Copy READ.md
file to directory src
.
cp README.md src/
Copy READ.md
file to directory src
and name the file test.md
.
cp README.md src/test.md
Moving Files
mv file_to_move destination
Examples
Move READ.md
file to directory src
.
mv README.md src/
Move READ.md
file to directory src
and name the file test.md
.
mv README.md src/test.md
Removing Files
rm file_to_remove
Process Concept
The program
can be thought of as a passive entity sitting on the disk meanwhile the process
is the active entity in execution, associated with resources.
There are 2 types of processes
.
IO bound processes
are those which spend more time doing the IO than the computations, having many but shortCPU
bursts.CPU bound processes
are those which spend more time doing computations, having longer but lessCPU
bursts.
Process States
New
The process
is being created.
Running
Instructions are being executed.
Waiting
The process is waiting for some event to occur, such as an IO
operation.
Ready
The process
is waiting to be assigned to a processor.
Terminated
The process
has finished execution.
Process state diagram
Process Control Block
Each process
is represented in the operating system
by a process
control block, also called a task control block
.
It has following pieces
Process State
The state
can be
- New
- Ready
- Running
- Waiting
- Halted
Program counter
The counter
indicates the address of the next instruction to be executed for this process
.
CPU
Registers
Depending on the architecture, these may vary in number of type.
- Accumulators
- Index Registers
- Stack Pointers
- General Purpose Registers
- Program Counter
CPU
Scheduling Information
This information includes
- Process Priority
- Pointers to Scheduling routines
- Scheduling parameters
Memory Management Information
This includes
- Base registers
- Limit registers
- Page tables
- Segment tables
Accounting Information
This includes
- Amount of CPU
- Real time used
- Time limits
- Account numbers
- Job or process numbers
IO
Status Information
This include
- List of
IO
devices allocated to theprocess
. - List of open
files
.
Process Scheduling
Switching the CPU
from one process to another requires us to save the context
of currently running process
.
Context Switching
Scheduling Queues
Job Queue
As processes
enter the system, they are put into a job queue
.
This queue
consists of all processes
in the system.
Ready Queue
This is a linked list
, with the header containing the pointers
to first and last process control block.
Each process control block includes a pointer
to point to next one.
Ready Queue
Device Queue
Each IO
device has its own device queue
which lists the processes
waiting for that device to be available for use.
Queuing Diagram
Schedulers
Long Term (job) Scheduler
Responsible for bringing processes
from job pool
to ready queue.
Short Term (CPU
) Scheduler
It selects which processes
need to be executed next and allocates CPU
.
- Short-term scheduler:
- Runs frequently (\(\approx\) every 100 ms).
- Must be fast to avoid
CPU
overhead.
- Long-term scheduler:
- Runs infrequently (minutes apart).
- Controls degree of multiprogramming.
- Balances
I/O bound
andCPU bound
processes for system efficiency.
- Medium-term scheduler (in some systems):
- Swaps processes between memory and disk (swap out / swap in).
- Frees memory or improves job mix.
- Uses
swap space
to store swapped-outprocesses
.
Computer system queues, servers, and swapping