Lecture 3 Os
Lecture 3 Os
Lecture 3
Hardware Dependent OS
• User Mode
• The system is in user mode when it runs normal user applications
like a text editor, browser, or game.
• In this mode, the program cannot access hardware directly or
perform critical system tasks.
Operating- • If a user program needs OS help (e.g., saving a file), it makes a
system call or interrupt, and the mode switches to kernel
System mode.
Operations • The mode bit is set to 1 in the user mode. It is changed from 1 to
0 when switching from user mode to kernel mode.
• Kernel Mode
• The system starts in kernel mode during boot-up and when the OS is in
control.
• In this mode, the system can directly access hardware, memory, and
execute privileged instructions (like I/O operations, interrupts, etc.).
• The mode bit is set to 0 in the kernel mode. It is changed from 0
to 1 when switching from kernel mode to user mode.
• If a user program tries to run privileged instructions in user mode, it
causes a trap (error), protecting the system.
Operating-System Operations
(cont.)
• Mode bit
Transition from User to Kernel Mode
Kernel Data Structures
• A shell is a command-line interface (CLI) that allows users to interact with an operating
system by executing commands. It serves as a bridge between the user and the OS kernel.
Operating systems are like the managers of a computer. They help programs run and make
sure everything works smoothly for both users and the computer.
• One set of operating-system services provides functions that are helpful to the user:
1.User Interface (UI): This is how users interact with the computer. Some systems use a
command-line interface (CLI), where you type commands. Others use a graphical
user interface (GUI), with windows, icons, and buttons. Some systems even use batch
processing, where tasks are run automatically without user input.
2.Program Execution: The operating system helps start and manage programs. It loads
programs into the computer’s memory and makes sure they run. If something goes wrong,
it can stop the program and show an error.
3.I/O Operations: When a program needs to read or write data (like opening a file or
printing something), the operating system handles it. It makes sure the program can talk
to the necessary devices, like printers, hard drives, or screens.
UFCPIERDAP
Operating System Services (Cont.)
4. File-System Manipulation: This is about managing files and folders (directories) on the computer. The operating
system allows programs to:
• Read and write files (open, save, modify).
• Create and delete files and directories.
• Search for files or directories.
• List information about files, like size, creation date, etc.
• Manage permissions, deciding who can access or modify files.
5. Communications: Sometimes, different programs (called processes) need to talk to each other. This could happen
within the same computer or over a network (like the internet). Communication can be:
• Shared memory, where multiple programs can access the same area of memory to exchange information.
• Message passing, where information is sent in packets (small data chunks) from one program to another, sometimes
across different computers.
6. Error Detection: The operating system always monitors for potential errors. These errors could be:
• In hardware, like problems with the CPU or memory.
• In I/O devices, like printers or hard drives failing.
• In user programs, if something goes wrong during the program's execution. The OS has to detect these errors and
decide what to do about them to keep the system running smoothly.
7. Debugging Facilities: The OS often includes tools that help debug programs. These tools help developers find and fix
issues in their programs, making the whole process of using and programming the system more efficient.
Operating System Services (Cont.)
Resource Allocation: When multiple users or programs (jobs) are running at the same time, the
operating system must manage and distribute the system's resources (like CPU power, memory,
storage, and I/O devices) fairly. This ensures that each user or program gets the resources they need to
function properly without interfering with others.
Accounting: The operating system keeps track of how much and what type of resources each user or
program is using. This helps with resource management and can also be useful for billing, auditing, or
ensuring fair usage.
• Multiprocessor Systems: More and more systems are using multiprocessors, which involve multiple processors working
together. These are also known as Parallel Systems or tightly-coupled systems. The key benefits of having multiple
processors are:
• Increased throughput: More processors mean more work can be done at the same time, leading to faster overall performance.
• Economy of scale: It's often cheaper to use multiple processors than to use a single, extremely powerful one.
• Increased reliability: If one processor fails, the system can still work using the remaining ones. This is called graceful degradation or fault
tolerance.
Types of
tasks in Operating the tasks of Operating
System. System.
Process Processor takes processes Master processor assign
rs Architecture
each processor.
All processor in
Symmetric
processes.
All processor in
Asymmetric
Multiprocessing has the Multiprocessing may have
same architecture. same or different
architecture.
Communication All processors Processors need not
communicate with communicate as they are
BPACF another processor by a controlled by the master
shared memory. processor.
Failure If a processor fails, the If a master processor fails,
computing capacity of the a slave is turned to the
system reduces. master processor to
continue the execution. If
a slave processor fails, its
task is switched to other
processors.
Symmetric Multiprocessing Architecture
Multiprocess Architecture – Chrome Browser
Types of Multiprogramming:
• Pre-emption (Time Sharing or Multitasking): In this type, the operating system forcefully removes a
process from the CPU after a set amount of time, allowing other processes to use the CPU. This is
common in systems where multiple users or tasks need to be handled simultaneously.
• Non-pre-emption: In this type, once a process starts using the CPU, it cannot be removed until it
finishes. This is used in systems where processes need to run to completion without interruption.
Degree of Multiprogramming: This refers to the maximum number of processes that can be in the ready
state (waiting to be processed) at once. For example, if the degree of multiprogramming is 100, it means
that the system can have up to 100 processes waiting to be executed at the same time.
Unitasking
• Pre-emptive Multitasking:
• OS forces switching from one process to another.
• Ensures fair sharing of CPU time.