Tuto 6-9 (OS) PDF
Document Details
![DefeatedNovaculite1923](https://quizgecko.com/images/avatars/avatar-7.webp)
Uploaded by DefeatedNovaculite1923
Universiti Malaysia Sarawak
Tags
Summary
These notes cover various topics in operating systems, including explanations of deadlock, starvation, race conditions, and different storage management methods like contiguous, non-contiguous, and indexed storage. The document also discusses file organization and access control mechanisms.
Full Transcript
## TUTORIAL 6 ### 1. What are the major differences between deadlock, starvation and race? * **Starvation:** Occurs when a scheduler process (i.e. the operating system) refuses to give a particular thread any quantity of a particular resource (generally CPU). If there are too many high-priority th...
## TUTORIAL 6 ### 1. What are the major differences between deadlock, starvation and race? * **Starvation:** Occurs when a scheduler process (i.e. the operating system) refuses to give a particular thread any quantity of a particular resource (generally CPU). If there are too many high-priority threads, a lower priority thread may be starved. This can have negative impacts, though, particularly when the lower-priority thread has a lock on some resource. * **Deadlock:** Occurs when two (or more) threads have created a situation where they are all blocking each other. Imagine that threads T1 and T2 need to acquire both resources A and B in order to do their work. If T1 acquires resource A, then T2 acquires resource B, T1 could then be waiting for resource B while T2 was waiting for resource A. In this case, both threads will wait indefinitely for the resource held by the other thread * **Race condition:** Occurs when two threads interact in a negative ( buggy ) way depending on the exact order that their different instructions are executed. If one thread sets a global variable, for example, then a second thread reads and modifies that global variable, and the first thread reads the variable, the first thread may experience a bug because the variable has changed unexpectedly. ### 2. Consider the following directed resource graph: **R1 -- P1 -- P2 -- R2** * **a) Is this system deadlocked?** Not yet * **b) Are there any blocked processes?** Not yet * **c) What is the resulting graph after reduction by P1?** * **d) Refer to question 2.c), what is the resulting graph after reduction by P2?** * **e) Both P1 and P2 have requested R2:** * **i. What is the status of the system if P2's request is granted before P1's?** The system is in an unstable state. There is no guarantee that P1 will release one of R1 needed by P2 to finish up. * **ii. What is the status of the system if P1's request granted before P2's?** The system will remain stable. P1 will then finish execution and release its resources so that P2 will also finish. ## TUTORIAL 8 ### 1. Other than hard disks, which of the following are also examples of secondary storage media: * **Punch cards** * **Read Only Memory (ROM)** * **Blu ray disc** * **Digital cameras** * **Floppy disks** * **Cloud file storage systems (i.e. Google docs)** * **Magnetic tape** * **USB thumb drive** * **CD** * **Memory sticks** * **Paper tape** ### 2. Describe how primary storage differs from secondary storage. * **Primary storage:** is temporary in nature because data there is lost when power is turned off. It is also called "main memory" and is used by the CPU to process jobs. * **Secondary storage:** is more permanent in nature (data there remains even when power is turned off) and is used by the operating system to keep data and applications over time. ### 3. Explain the differences between buffering and blocking. * **Buffering:** is a storage-saving technique that groups individual records into a block that's stored and retrieved as a unit so it can written and/or read more efficiently. * **Blocking:** means data is written to a temporary area while it waits to go to an I/O device (such as a monitor), and are often used to allow a fast resource to work with a slow resource, or vice versa. ## TUTORIAL 9 ### 1. The efficiency of File manager depends on few criteria: * **How the system's file are organized:** sequential, direct, or indexed sequential * **How each file's records are structured:** fixed-length or variable-length * **How accesses to these files are controlled:** access control matrix, access control lists, capability lists * **How they are stored:** contiguously, noncontiguously, or indexed ### 2. The responsibilities of file manager include four tasks: * Keep track of where each file is stored * Use a policy that will determine where and how the files will be stored, making sur e to efficiently use available storage space and provide efficient access to files. * Allocate each file when a user has been cleared for access to it, and then record its use. * Deallocate the file when the file is to be returned to storage, and communicate its availability to others who may be waiting for it. ### 3. How does user communicate with file manager? The user communicates with the File Manager, which responds to specific commands. The commands include: * **OPEN** * **COPY** * **DELETE** * **RENAME** ### 4. Describe and give differences of fixed-length records and variable-length records. * **Variable-length records:** * Do not leave empty storage space and do not truncate any characters. * Harder to calculate exactly where the record is located. * If the record size is too large, the space is wasted. * **Fixed-length records:** * Used most frequently in files that are likely to be access sequentially. * Easier to access directly. * Loading is faster. * Access is faster. * Processing is slower. * The record size is the critical aspect. ### 5. Define absolute filename and relative filename? * **Absolute filename:** complete filename which is the long name that includes all path information * **Relative filename:** indicates the filename without path information that appears in directory listings and folders * **dir1/dir2/dir3/myfile:** Absolute filename * **Tutorial9:** Relative filename * **C:/Documents/OSTutorial:** Absolute filename * **myfile:** Relative filename ### 6. Explain contiguous, non-contiguous and indexed storage, and include figures to explain it clearly by determining whether the following are contiguous, non-contiguous OR indexed storage. * **Contiguous storage:** Records stored one after another * **Non-contiguous storage:** Allows files to use any storage space available on the disk * **Indexed storage:** Allows direct record access by bringing together the pointers linking every extent of that file into an index block * **Contiguous storage:** A file cannot be expanded unless there’s empty space available immediately. * **Non-contiguous storage:** No direct access support. * **Indexed storage:** It does not necessarily improve the use of storage space because each file must have an index block. [Here you'd include a visual representation of each storage type with the corresponding caption.] ### 7. The following directory table lists files' starting address, ending address, and the number of extents it uses. Given the size of File 1 is 768 bytes, File 2 is 1536 bytes, and the physical size of each extent is 256 bytes. Calculate the number of required extents to store File 1 and File 2. Then draw a diagram of noncontiguous file storage to store both files (with row-by-column matrix: 5x6) with linking taking place at the storage level. 1. **Calculate the number of required extents to store File 1 and File 2.** | File No. | Start | End | No. of extents | |---|---|---|---| | 1 | 7 | 29 | 3 | | 2 | 5 | 15 | 6 | 2. **Draw a diagram of noncontiguous file storage to store both files (with how-by-column matrix: 5x6) with linking taking place at the storage level.** | 1 | 2 | 3 | 4 | 5 | 6 | |---|---|---|---|---|---| | File 1 | File 2 | File 2 | File 1 | File 2 | File 2 | | File 2 | File 1 | File 2 | File 1 | File 2 | File 1 | | File 2 | File 2 | File 2 | File 1 | File 2 | File 1 | | File 2 | File 1 | File 2 | File 1 | File 2 | File 1 | | File 1 | File 2 | File 1 | File 2 | File 1 | File 2 | ### 8. Given the following table, draw a diagram of noncontiguous file storage for File 3 (with row-by-column matrix: 5x6) with linking taking place at the directory level. | File | Address | Size | Next | |---|---|---|---| | File 3 (1) | 4 | 256 | 7 | | File 3 (2) | 7 | 256 | 19 | | File 3 (3) | 19 | 256 | | | 1 | 2 | 3 | 4 | 5 | 6 | |---|---|---|---|---|---| | FILE 3 (1) | | | | | | | FILE 3 (2) | | | | | | | FILE 3 (3) | | | | | | ### 9. Given the following diagram of noncontiguous file storage for indexed storage allocation with a one-level index, draw the index table for File 1, File 2 and File 3. | File | Index Block | |---|---| | File 1 | 10 | | File 2 | 8 | | File 3 | 5 | ### 10. For each of the following entries in an access control matrix for User 2010, give the type of access allowed for each of the following files: * **File 1:** --E-- (execute only access) * **File 2:** RWED (read, write, execute and delete access) * **File 3:** R--E (read and execute access) * **File 4:** R--- (read only access) ### 11. For each of the following entries in an access control list, give the type of access allowed for each user of the File221 and describe who is included in the WORLD category. * **USER2010:** R--E (read and execute access) * **USER2014:** --E-- (execute only access) * **USER2017:** RWED (read, write, execute and delete access) * **WORLD:** R--- (read only access - WORLD includes all users that are not included in subgroup)