0% found this document useful (0 votes)
6 views

OS

An Operating System (OS) serves as an interface between users and computer hardware, managing resources such as memory, processes, and I/O devices. It provides essential services for applications, ensuring efficient execution and security while abstracting hardware complexities. Key roles of an OS include resource management, control of program execution, and offering services like file management and inter-process communication.

Uploaded by

lalithabhashini
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)
6 views

OS

An Operating System (OS) serves as an interface between users and computer hardware, managing resources such as memory, processes, and I/O devices. It provides essential services for applications, ensuring efficient execution and security while abstracting hardware complexities. Key roles of an OS include resource management, control of program execution, and offering services like file management and inter-process communication.

Uploaded by

lalithabhashini
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
You are on page 1/ 12

OS

An Operating System (OS) is an interface between a computer


user and computer hardware. An operating system is a software
which performs all the basic tasks like file management, memory
management, process management, handling input and output,
and controlling peripheral devices such as disk drives and
printers.
An operating system is software that enables applications to
interact with a computer's hardware. The software that contains
the core components of the operating system is called
the kernel.
The primary purposes of an Operating System are to enable
applications (spftwares) to interact with a computer's hardware
and to manage a system's hardware and software resources.
Some popular Operating Systems include Linux Operating
System, Windows Operating System, VMS, OS/400, AIX, z/OS,
etc. Today, Operating systems is found almost in every device
like mobile phones, personal computers, mainframe computers,
automobiles, TV, Toys etc.
Definitions
We can have a number of definitions of an Operating System.
Let's go through few of them:
An Operting System is the low-level software that supports a
computer's basic functions, such as scheduling tasks and
controlling peripherals.
We can refine this definition as follows:
An operating system is a program that acts as an interface
between the user and the computer hardware and controls the
execution of all kinds of programs.
Following is another definition taken from Wikipedia:
An operating system (OS) is system software that manages
computer hardware, software resources, and provides common
services for computer programs.

Architecture
We can draw a generic architecture diagram of an Operating
System which is as follows:
Following are some of important functions of an operating
System.
 Memory Management

 Processor Management

 Device Management

 File Management

 Network Management

 Security

 Control over system performance

 Job accounting

 Error detecting aids

 Coordination between other software and users


. Computer Architecture Fundamentals:
 CPU Architecture:

o Registers: Small, fast storage locations within the CPU.

Examples: Program Counter (PC), Accumulator (ACC),


Stack Pointer (SP).
o Instruction Cycle (Fetch-Decode-Execute): The CPU

fetches an instruction from memory, decodes it, and


then executes it.
o Interrupts: Signals from hardware or software that

interrupt the normal execution of the CPU and allow it


to handle events.
 Memory Hierarchy: A system of multiple levels of memory,

each with different speed, cost, and capacity.


o Cache: Small, fast memory close to the CPU. Levels of

cache (L1, L2, L3). Cache coherence ensures that all


CPUs have a consistent view of data in the cache.
o RAM (Random Access Memory): Main memory. DRAM

(Dynamic RAM), SRAM (Static RAM).


o Secondary Storage: Non-volatile storage for persistent

data. Hard disks, SSDs.


 I/O Devices and Controllers: Devices that allow the

computer to interact with the outside world (e.g., keyboard,


mouse, monitor, disk drives). Controllers are hardware
interfaces that manage communication between the CPU and
I/O devices.
 Basic Understanding of Assembly Language: A low-level

programming language that is close to machine code.


Understanding assembly language helps understand how
software interacts with hardware.
3. Processes:
 Process Concept: A program in execution. A program is a

static set of instructions, while a process is a dynamic entity


with its own resources (memory, files, etc.).
 Process States:

o New: The process is being created.

o Ready: The process is waiting to be assigned to the

CPU.
o Running: The process is currently executing on the CPU.

o Blocked (Waiting): The process is waiting for an event

(e.g., I/O completion).


o Terminated: The process has finished execution.

 Process Control Block (PCB): A data structure that stores all

the information about a process (e.g., process ID, state,


registers, memory allocation, open files).
 Process Scheduling: The process of deciding which process

should run on the CPU.


o FCFS (First-Come, First-Served): Processes are executed

in the order they arrive.


o SJF (Shortest Job First): The process with the shortest

execution time is run next.


o Priority: Processes are assigned priorities, and the

highest priority process is run.


o Round Robin: Each process is given a time slice

(quantum) of CPU time.


 Context Switching: The process of saving the state of one

process and loading the state of another process. This allows


the CPU to switch between processes.
4. Threads:
 Threads vs. Processes: A process can have multiple threads.

Threads share the same address space as their parent


process, but they have their own stack and registers.
 Multithreading: The ability to have multiple threads of
execution within a single process.
 Benefits of Threads: Improved responsiveness (e.g., a GUI

application can remain responsive while a long task is


performed in a background thread), concurrency (multiple
threads can execute concurrently on multiple cores),
resource sharing (threads within a process share the same
memory and other resources).
 Thread Synchronization: Mechanisms to coordinate the

execution of multiple threads and prevent race conditions


(where the outcome of a program depends on the
unpredictable order in which threads execute).
o Mutexes: Mutual exclusion locks. Only one thread can

hold a mutex at a time.


o Semaphores: Signaling mechanisms. Can be used to

control access to shared resources.


o Condition Variables: Allow threads to wait for a specific

condition to become true.


This detailed explanation should give you a much stronger
understanding of the core concepts of operating systems.
Remember to consult textbooks and other resources for further
information and examples. Practical exercises and coding are
essential to solidify your understanding.
key roles explain
Let's break down the key roles of an operating system in more
detail:
1. Resource Management: This is arguably the most crucial
role. The OS acts as a central manager for all the computer's
resources, ensuring they are used efficiently and fairly. This
includes:
o CPU Management: The OS determines which process

gets to use the CPU and for how long. This is called
scheduling. The goal is to maximize CPU utilization,
minimize waiting times, and provide a fair allocation of
processing power. Different scheduling algorithms (like
those discussed previously) are used to achieve these
goals.
o Memory Management: The OS manages the

computer's memory (RAM). It allocates memory to


processes, keeps track of which parts of memory are in
use, and reclaims memory when it's no longer needed.
Crucially, it also handles virtual memory, which allows
processes to access more memory than is physically
available by using secondary storage (like a hard drive)
as an extension of RAM.
o Storage Management: The OS manages secondary

storage devices like hard drives and SSDs. This involves


organizing files and directories, providing access
methods to files, and managing disk space. It also
handles tasks like formatting disks and managing file
system permissions.
o I/O Management: The OS manages communication

with input/output devices (keyboard, mouse, printer,


network interfaces, etc.). It provides a consistent
interface for applications to interact with these devices,
handles interrupts from devices, and often uses
buffering and caching to improve I/O performance.
2. Abstraction: The OS provides a simplified and consistent
interface to the hardware. This means that application
programmers don't need to worry about the low-level details
of how the hardware works. Instead, they can use system
calls to request services from the OS, which then handles the
interaction with the hardware. This abstraction makes it
much easier to develop applications and also makes
applications more portable (they can run on different
hardware platforms as long as the OS provides the same
system call interface).
3. Control: The OS controls the execution of programs. This
includes:
o Starting and stopping programs: The OS loads

programs into memory and initiates their execution. It


also provides mechanisms for terminating programs.
o Preventing errors: The OS protects the system from

errors caused by user programs. For example, it


prevents programs from accessing memory that they
are not authorized to use.
o Managing concurrency: The OS manages the

concurrent execution of multiple programs (or threads).


This involves scheduling processes and threads, and
providing synchronization mechanisms to prevent
conflicts when multiple programs access shared
resources.
o Security: The OS provides security features to protect

the system from unauthorized access and malicious


software. This includes user authentication, access
control, and protection against viruses and other
malware.
4. Services: The OS provides a set of essential services that
applications can use. These services include:
o File management: Creating, deleting, reading, and

writing files.
o Process management: Creating, deleting, and managing

processes and threads.


o I/O operations: Communicating with I/O devices.

o Inter-process communication (IPC): Allowing processes

to communicate with each other.


o Networking: Providing network access.
In summary, the OS is the foundation upon which all other
software runs. It manages the computer's resources, provides a
simplified interface to the hardware, controls the execution of
programs, and offers a set of essential services. Without an OS, it
would be extremely difficult to use a computer.
system Calls:
System calls are the fundamental interface between a user-level
process and the operating system kernel. They are the way a
program requests services from the OS, such as accessing files,
managing memory, or creating processes. Think of them as the
"official" way for a program to ask the OS to do something on its
behalf.
Here's a breakdown of key aspects of system calls:
 Purpose: System calls provide a controlled and secure way

for user programs to access kernel functionality. The kernel is


responsible for managing hardware and other system
resources, and it's crucial to prevent user programs from
directly manipulating these resources, as that could lead to
instability or security breaches. System calls act as a
gatekeeper, ensuring that all requests are validated and
handled properly by the kernel.
 Mechanism: When a program makes a system call, it typically

involves the following steps:


1. The program sets up the arguments for the system call
(e.g., the name of a file to open, the data to write).
These arguments are often placed in registers or on the
stack.
2. The program executes a special instruction (often a
"trap" or "syscall" instruction) that causes a switch to
kernel mode.
3. The kernel receives the system call request. It uses a
system call number (or similar mechanism) to identify
the specific system call being requested.
4. The kernel validates the arguments provided by the
user program. This is a critical security step to prevent
malicious or erroneous requests.
5. If the arguments are valid, the kernel performs the
requested operation. This might involve interacting
with hardware, managing memory, or manipulating
files.
6. The kernel sets a return value (e.g., success or an error
code) and returns control to the user program.
7. The user program continues execution, now with the
results of the system call.
 Examples: Here are some common examples of system calls:
o open(): Opens a file for reading or writing.
o read(): Reads data from a file.
o write(): Writes data to a file.
o close(): Closes a file.
o fork(): Creates a new process.
o exec(): Replaces the current process image with a new
program.
o exit(): Terminates the current process.
o malloc() (and related functions): Allocates memory
(often implemented using system calls like brk or
mmap).
o sleep(): Suspends the execution of a process for a
specified time.
o getpid(): Gets the process ID of the current process.
MEMORY MANAGEMENT ^^^

PROCESS MANAGEMT
What does an operating system do?
An operating system manages computer hardware and software, coordinates tasks, and
provides a user interface for interacting with the computer.

Difference Between System Software and Operating System


Major Difference between System Software and Operating System
 Scope: Operating system is a type of system software, but system software is not
limited to operating system only. System software includes various other programs
that help to manage and run the computer system, such as device drivers, language
translators, utility programs, and more.
 Function: Operating system is the main program that manages and controls all the
other software and hardware components of the computer. It provides a platform
for other software applications to run on top of it. System software, on the other
hand, provides tools and services to help developers create and manage software
applications.
 Importance: Operating system is an essential component of any computer system.
Without an operating system, a computer cannot function. System software, on the
other hand, is important but not essential. Some applications can run without
system software, but they may not be able to utilize the full power of the computer
system.
 Complexity: Operating systems are usually more complex than other types of
system software. They have to manage hardware resources, provide security, and
support various software applications. System software, on the other hand, can be
relatively simple in comparison, depending on its purpose.
Conclusion
System software is the basic software that runs your computer. It controls all the parts
inside your computer and makes sure they work together. The most important system
software is called an operating system. It helps you use your computer by connecting
you to the machine’s parts. The operating system also lets you run other programs on
your computer. Without system software, especially the operating system, your
computer wouldn’t be able to do anything.

You might also like