140 OS
140 OS
ISLAMABAD, SAHIWAL
CAMPUS
ASSIGNMENT NO.01
DEPARTMENT OF COMPUTER
SCIENCE
Question 1
How does the distinction between kernel mode and user mode function as a
rudimentary form of protection (security)?
User Mode:
A restricted mode where applications run with limited access to system resources.
Programs in user mode cannot directly interact with hardware or critical system
functions to prevent system crashes or security breaches
Characteristics:
Example: Suppose you are running a word processor on your computer. This
application operates in user mode.
Kernal Mode:
A privileged mode where the operating system operates with full access to all hardware
and system resources. The kernel has complete control over the system and handles tasks
like memory management, device drivers, and hardware communication.
Characteristics:
The difference between kernel mode and user mode helps ensure basic security by
controlling access to important system functions. In kernel mode, the operating
system can freely access hardware and perform sensitive tasks, while in user mode,
regular programs are restricted from directly accessing these resources. This
separation prevents user programs from doing anything harmful, as they need to ask
permission through system calls for any privileged actions. By managing access this
way, the system stays protected from unauthorized or accidental damage, keeping
both the operating system and other programs safe.
References:
Silberschatz, A., Galvin, P. B., & Gagne, G. (2020). Operating System Concepts (8th
ed.). Wiley.
Question No 2
Explain the role of system calls in an operating system. Choose a few specific
system calls and describe how they interact with hardware to provide
essential services to application
System calls act as a bridge between user applications and the operating system, allowing
programs to request services that they don't have direct access to, such as interacting with
hardware. Since user applications run in a restricted user mode for security reasons, they rely on
system calls to access critical resources managed by the operating system in kernel mode.
For example: We have Some System calls and its work is given below:
read():
When an application wants to read data from a file, it uses the read() system call. This is like
asking the operating system to get the data from storage, such as a hard drive. The operating
system, using the kernel, communicates with the hardware to retrieve the data safely. This prevents
the application from directly handling the hardware, which could lead to mistakes or security
problems.
fork():
Another system call is fork(), which is used to create new processes. When an application calls
fork(), the operating system makes a copy of the current process, giving it the necessary memory
and resources to run. The kernel ensures everything is set up properly for the new process while
keeping control over how resources are shared between processes.
write():
The write() system call is used when an application needs to send data to a device (like a printer)
or save data to a file. The operating system takes the request and interacts with the hardware (like
the file system or printer) to ensure the data is written correctly