0% found this document useful (0 votes)
86 views4 pages

User Mode

Here is a Python code to create a new process with one child and one parent: ```python import os import time def child_process(): print("Hello from the child!") def parent_process(): print("Hello from the parent!") pid = os.fork() if pid == 0: child_process() else: print(f"Created a child process with PID: {pid}") time.sleep(1) print("Parent exiting.") parent_process() ``` This code: - Defines a child_process() function that will run in the child - Defines a parent_process() function that will: - Print

Uploaded by

fikadu
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)
86 views4 pages

User Mode

Here is a Python code to create a new process with one child and one parent: ```python import os import time def child_process(): print("Hello from the child!") def parent_process(): print("Hello from the parent!") pid = os.fork() if pid == 0: child_process() else: print(f"Created a child process with PID: {pid}") time.sleep(1) print("Parent exiting.") parent_process() ``` This code: - Defines a child_process() function that will run in the child - Defines a parent_process() function that will: - Print

Uploaded by

fikadu
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/ 4

1) Mention all conditions that can cause deadlock?

And the strategies to deal with it

There are following 4 necessary conditions for the occurrence of deadlock-


1. Mutual Exclusion
2. Hold and Wait
3. No preemption
4. Circular wait

2 Explain in detail the modes of operating system.

A processor in a computer running Windows has two different modes: user


mode and kernel mode.

The processor switches between the two modes depending on what type of code is
running on the processor. Applications run in user mode, and core operating system
components run in kernel mode. While many drivers run in kernel mode, some drivers
may run in user mode.

User Mode
The system is in user mode when the operating system is running a user application
such as handling a text editor. The transition from user mode to kernel mode occurs
when the application requests the help of operating system or an interrupt or a system
call occurs.
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 when it boots and after the operating system is
loaded, it executes applications in user mode. There are some privileged instructions
that can only be executed in kernel mode.
These are interrupt instructions, input output management etc. If the privileged
instructions are executed in user mode, it is illegal and a trap is generated.
3 What are the different types of schedulers? And the difference between them?

 Three types of the scheduler are 1) Long term 2) Short term 3) Medium-
term
 Long term scheduler regulates the program and select process from the
queue and loads them into memory for execution.
 The medium-term scheduler enables you to handle the swapped out-
processes.
 The main goal of short term scheduler is to boost the system
performance according to set criteria
 Long term is also known as a job scheduler, whereas the short term is
also known as CPU scheduler, and the medium-term is also called
swapping scheduler.

escribe the differences among short-term, medium-term, and longterm


scheduling.

Answer:

• Short-term (CPU scheduler)—selects from jobs in memory those

jobs that are ready to execute and allocates the CPU to them.

• Medium-term—used especially with time-sharing systems as an

intermediate scheduling level. A swapping scheme is implemented

to remove partially run programs from memory and reinstate them

later to continue where they left off.

• Long-term (job scheduler)—determines which jobs are brought into

memory for processing.

4 What is abstraction in operating system

One of the main points and features of a filesystem is abstraction. With a filesystem, we can
organize our data into files, directories, and other constructs, and manipulate them in various ways.

This data abstraction is important for several reasons:

 Portability; it's not necessary to port every program for all hardware, only the device drivers
need to be changed.
 Security; the user is not relied on ‒ or even allowed ‒ to access the drive directly.
 Convenience; files don't actually exist as separate entities on disk, but it sure makes it easier
for people to use computers.

5) What is DMA?

Direct Memory Access (DMA) transfers the block of data between


the memory and peripheral devices of the system, without the
participation of the processor. The unit that controls the activity of accessing
memory directly is called a DMA controller

Direct memory access (DMA) is a feature of computer systems that allows certain


hardware subsystems to access main system memory (random-access memory)
independently of the central processing unit (CPU). ... DMA can also be used for
"memory to memory" copying or moving of data within memory.

6) Differentiate the types of OS structure? Which one is advisable to use

General-purpose OS is very large program

 Various ways to structure ones

 Simple structure – MS-DOS

 More complex -- UNIX

 Layered – an abstrcation

 Microkernel –Mach

MS-DOS – written to provide the most functionality in the least space

7) Give three examples of scheduling algorithm?

 First-Come, First-Served (FCFS) Scheduling


 Shortest-Job-Next (SJN) Scheduling
 Priority Scheduling
 Shortest Remaining Time
 Round Robin(RR) Scheduling
 Multiple-Level Queues Scheduling
8) What is interrupt? At what condition does it occur?
Interrupt is a signal emitted by hardware or software when a process or an
event needs immediate attention. It alerts the processor to a high-priority
process requiring interruption of the current working process. In I/O devices one
of the bus control lines is dedicated for this purpose and is called the Interrupt
Service Routine (ISR). 
Interrupts in embedded systems are much like subroutines, but they are generated by
hardware events rather than software calls.
9) Type a code to create a new process with one child and one parent?

You might also like