OS 2 : Internal Exam : TYBCS Semester 6 SPPU - BCS Guruji

Ad

Tuesday, March 5, 2024

OS 2 : Internal Exam : TYBCS Semester 6 SPPU

  Syllabus: Chapter 1, Chapter 2 and Chapter 3 half


CHAPTER 1: 


Q. Define Starvation?

- When a process waits for a long time for its resources, then the process is said to be in a situation of starvation.


Q. Explain the term 'select a victim and rollback' in the context of deadlock recovery.

- A. Select a victim: It is the process of selecting the process and resources for pre-emption. It is done based on three criterias- 

1. Priority- Resource of low priority processes will be preempted

2. Own Cost: Process that has completed very less of it's execution will be preempted.

3. Cost affecting other processes: How many maximum process can restart their execution if resources of a particular process P are pre-empted.

-B. Rollback: The process, from which the resources are preempted, will not be able to continue it's execution, such a process is said to be rolled back to some safe state.


Q. Wait for a graph is used for deadlock avoidance in the system. True/False

Q.What is deadlock? State different methods to handle a deadlock.

- Deadlock: A deadlock occurs when a process enters a waiting state because a requested system resource is held by another waiting process, which in turn is waiting for another resource held by another waiting process.

Each process waits for an event that cannot occur, therefore this situation is called as a deadlock.

Q. Explain deadlock prevention strategies.

- There are 4 strategies for deadlock prevention:

1. Eliminate mutual exclusion condition: Mutual exclusion is a condition which says that several process cannot share a single resource at a time. We can eliminate this condition to prevent deadlock. But it cannot be used in all cases, like printers, which cannot print 2 outputs at a time, and hence can handle only one process at a time...

2. Eliminate hold and wait condition: Hold and wait is a condition where a process is holding a resource and also waiting for another requested resource which is being held by some other resource. We can eliminate this condition by either allocating all required resources to the process before it starts its execution, or we can eliminate by not allowing any process to request any more resource until it releases the holded resource.

3. Eliminate No Preemption condition: No preemption is a condition, where if one process is holding a resource then that resource cannot be taken away from that process until the process releases that resource voluntarily. But we can eliminate no preemption only when that resource's working state can be saved and later restored. 

4.Eliminating Circular wait condition:  A circular wait occurs when one or more processes wait in a circular order for the resources they require. It can be eliminated by assigning a priority number to each available resource, and process will be granted that resource only when the priority number of requested resource is higher than currently held resource.


Q. What is a wait-for-graph?

- Wait for graph is a variation of resource allocation graph. It shows the dependency of a process on another process for resource allocation. It only contains process and not the resources. 

Suppose P1->R1 and R1->P2, then there will be edge from P1->P2... 

To detect a deadlock, system needs to maintain a wait for graph and check of cycles in the graph.

As there is a cycle in P1->P2->P4->P1, this is a deadlock situation.


Q. Define request edge and claim edge.

- Request Edge: It is a directed edge from a process to a resource. Pi->Rj is called request edge.

- Claim Edge: It is a dashed line that indicates that process may request a resource in the future. Pi--->Rj


Q. State necessary conditions for deadlock to occur.

- Conditions for deadlock that must hold simultaneously: 

1. Mutual Exclusion: Mutual exclusion is a condition which says that several process cannot share a single resource at a time. Only one process at a time can use a non-shareable resource.

2.Hold and wait condition: Hold and wait is a condition where one resource is waiting to acquire additional resource held by other processes.

3. No-Preemption: Resources allocated to a process cannot be preempted until its completion or released voluntarily by the process holding it.

4. Circular wait condition: The process in a system form a circular list of chain, where each process waits for resource held by another process.


Q. Explain ways for deadlock recovery.

- There are 2 ways for deadlock recovery:

1. Process Termination: There are two methods for terminating processes:

A. Kill all deadlocked proccesses (more expensive method)

B. Kill one process at a time until deadlock is eliminated ( more overhead). The proccess are killed based on cost, priority, etc.

2. Resource Pre-emption: It is a process of pre-empting resources from the other processes one by one and allocate them to other process until deadlock is eliminated.

It has three decisions to be taken:

A. Selecting a process for preemption: A process is selected such that it has low priority, low cost (completed very less of its execution), and how many other process can start after preemption of this process.

B. Rollback: The process from which resources are preempted is said to be roll backed.

C. Prevent Starvation: A process is said to be starving when its waiting for its resources for long time, and this can be eliminated by making sure that a particular process is not selected again and again for preemption/



Numericals:

Q. What is content of need matrix, is the system in safe state? if yes, give the safe sequence.

Q. Is the system deadlocked, if so, which processes are involved.


CHAPTER 2: 

Q. Discuss the various techniques of free space management in file system. 

Q. Explain tree structured directories along with advantages and disadvantages.

Q. What are various dynamic allocation memory management methods.

Q. Give any two disk allocation methods.

: Allocation method is how files are stored in the disk blocks.

There are 3 methods:

1. Contiguous Allocation: 

2. Linked Allocation:

3. Indexed Allocation: 

Q. List any four file attributes.

- Following are file attributes:

1. Name: It is a string of characters.

2. Identifier: It is a tag(a number) that identifies the file in system.

3. Type: It specifies that type of file.

4. Location: It is a pointer to a device and location of file on that device.

5. Size: It is current size of files in bytes or blocks.


Q. Explain different methods for handling free space list in file system.

Q. Explain file operations in detail.

- Following are some file operations:

1. Create Operation: Find a space for new file in system, make an entry for new file in directory and create new file.

2. Write Operation: Perform system call to search file name in directory, find tis location, place the writer pointer to location and update when write occurs.

3. Reading Operation: Perform system call with file name, search in directory, place read pointer to location, update read pointer when read occurs.

4. Reposition or Seek Operation: Search file name in directory, current pointer position is repositioned to given value.

5. Delete Operation: Search file name in directory, release all file space, erase directory entry.

6. Truncate Operation: It is a process to erase contents of file and keep the attributes same expect for file length. So file length becomes zero, and file space is released but file isnt deleted.

7. Open Operation: Perform a system call with file name to open the file before performing any operation.

8. Close Operation: On closing it de-allocates internal descriptors that were created while opening the file.

9. Append Operation: Adds data to end of file.

10. Rename Operation: Used to rename  existing file.


Q. Define acyclic graph directoy.

Q. Define different file access methods.

Q. Newly created directory will have two entries in it. Comment.

Q. What is a bit vector?

Q. Write file access methods.

Answer: There are three file access mechanisms:

1. Sequential Access: Here information of file is processed in order, one record after the other. 

Read next reads next portion of file, write next appends to end of file , and pointer is advanced to new location. Rewinding will reset file pointer to the beginning.

It is simple. But time consuming.

2. Direct Access: Here records are accessed directly. Read n, where file pointer is placed at nth block and reads data of that block. Write n, where operations writes data into nth block.

We can randomly access records.

3. Indexed Access: Index is a seperate file from master file containing key of each record. It is fastest way to access a file. 

- Indexed Sequential: Master file is sorted according to key values. Index table contains only some keys of the records.

- Indexed Non-sequential:  Master file is not in any specified order. There is one entry in index for every record.


No comments:

Post a Comment