You are on page 1of 5

PROBLEM SOLVING FORMAT

Name: Rodjean A. Simballa Date: Grade:

Course & Section: Topic: Lesson 3: Process Management


BSIT 3D
Question and Answer:

1. What is an instruction trace?


Answer:
A list of the sequence of instructions that are executed by an individual process

2. What common events lead to the creation of a process?


Answer:
-New batch job
-Interactive Login
-Created by OS to provide a service
-Spawned by existing process

3. For the processing model of this following figure, briefly define each state.

Answer:
1) New: The process has not yet been loaded into main memory.
2) Ready: the process is now prepared to execute when given the opportunity.
3) Running: the process is currently being executed.
4) Blocked: Process that is waiting for some event to occur.
5) Exit: Process is released from main memory because it has halted or aborted.
4. What does it mean to preempt a process?
Answer:
To maximize the number of processes in the system, we swap a process from the ready state to
the ready suspend state (i.e. give its memory to another process)

To take a resource away from a process. One such resource is the CPU, and in fact preempt often
means to move a process from RUNNING state to READY state. The process involuntarily gives up the CPU.

5. Why are two modes (user and kernel) needed?


Answer:
Need of Double Mode in Working Framework. A running client program can accidentally wipe out
the working framework by overwriting it with client information. Different forms can compose within
the same framework at the same time, with lamentable comes about.

6. What are the steps performed by an OS to create a new process?


Answer:
 Assign a unique process identifier to the new process.
 Allocate space for the process.
 Initialize the process control block.
 Set the appropriate linkages.
 Create or expand other data structures.

7. What is the difference between an interrupt and a trap?


Answer:

8. List reasons why a mode switch between threads may be cheaper than a mode switch between
processes.
Answer:
1.reason – the control blocks for processes are larger
than for threads (hold more state information), so the
amount of information to move during the thread switching
is less than for process context switching

2. reason – the major reason is that the memory management


is much simpler for threads than for processes. Threads
share their memory so during mode switching, memory
information does not have to be exchanged/changed, pages
and page tables do not have to be switched, etc. This makes
the thread context switch much cheaper than for processes.
In case of processes the memory pieces (pages) need to be
exchanged, etc. (Will talk about the details in few weeks).

3. reason – threads do not have to worry about accounting,


etc, so do not have to fill out all the information about
accounting and other process specific information in their
thread control block, so keeping the thread control block
consistent is much faster

4. reason – threads share files, so when mode switch


happens in threads, these information stay the same and
threads do not have to worry about it (similar to
accounting information) and that makes the mode switch much
faster.

9. Give four general examples of the use of threads in a single-user multiprocessing system.
Answer:
Foreground and background work: For example, in a spreadsheet program, one thread could
display menus and read user input, while another thread executes user commands and updates the
spreadsheet. This arrangement often increases the perceived speed of the application by allowing the program
to prompt for the next command before the previous command is complete.

Asynchronous processing: Asynchronous elements in the program can be implemented as threads. For
example, as a protection against power failure, one can design a word processor to write its random access
memory (RAM) buffer to disk once every minute. A thread can be created whose sole job is periodic backup
and that schedules itself directly with the OS; there is no need for fancy code in the main program to provide
for time checks or to coordinate input and output.

Speed of execution: A multithreaded process can compute one batch of data while reading the next batch
from a device. On a multiprocessor system, multiple threads from the same process may be able to execute
simultaneously. Thus, even though one thread may be blocked for an I/O operation to read in a batch of data,
another thread may be executing.

Modular program structure: Programs that involve a variety of activities or a variety of sources and
destinations of input and output may be easier to design and implement using threads.
10. What resources are typically shared by all of the threads of a process?
Answer:
All of the threads of a process share the state and resources of that process.

They reside in the same address space and have access to the same data. When one thread alters an item of
data in memory, other threads see the results if and when they access that item. If one thread opens a file with
read privileges, other threads in the same process can also read from that file.

11. List three advantages of ULTs over KLTs.


Answer:
 Thread switching does not require kernel mode privileges
 Scheduling can be application specific
 ULTs can run on any OS

12. List two disadvantages of ULTs compared to KLTs.

Answer:
 One thread be blocked, whole process be blocked.
But many system calls are blocking.
 A multi-threaded application cannot take advantage of multiprocessing.

13. Give examples of reusable and consumable resources.


Answer:
 Examples of reusable resources are processors, I/O channels, main and secondary memory, devices,
and data structures such as files, databases, and semaphores.
 Examples of consumable resources are interrupts, signals, messages, and
information in I/O buffers.F

14. What are the four conditions that create deadlock?


Answer:

Mutual exclusion.
Only one process may use a resource at a time.
Hold and wait.
A process may hold allocated resources while awaiting assignment of others.

No preemption.
No resource can be forcibly removed from a process holding it
The above three conditions, plus: Circular wait. A closed chain of processes exists,
such that each process holds at least one resource needed by the next process in the
chain.s

15. What is the difference among deadlock avoidance, detection, and prevention?

Answer:

Deadlock prevention constrains resource requests to prevent at least one of the our conditions of
deadlock; this is either done indirectly, by preventing one of the three necessary policy conditions
(mutual exclusion, hold and wait, no preemption), or directly, by preventing circular wait.

Deadlock avoidance allows


the three necessary conditions, but makes judicious choices to assure that the
deadlock point is never reached.

Deadlock detection, requested resources are


granted to processes whenever possible.; periodically, the operating system
performs an algorithm that allows it to detect the circular wait condition.

You might also like