Operating systems Final Q/A

¡Supera tus tareas y exámenes ahora con Quizwiz!

Researchers have suggested that, instead of having an access list associated with each file (specifying which users can access the file, and how), we should have a user control list associated with each user (specifying which files a user can access, and how). Discuss the relative merits of these two schemes.

When maintained for each file: less space requirement, information is stored at one place that specifies which users can access each file. When maintained per user: better when better performance is required - it costs less overhead to open a file

Some systems provide file sharing by maintaining a single copy of a file. Other systems maintain several copies, one for each of the users sharing the file. Discuss the relative merits of each approach

With a single file, there is a chance that the user make encounter an updated file. With multiple copies, there is more space requirement, copies may not be consistent with each other. An acyclic graph that shares files and directories makes more than one copy. In this case, changes amongst separate copies aren't reflected within each other. In shared files, files are updated accordingly.

Discuss the advantages and disadvantages of associating with remote file systems (stored on file servers) a set of failure semantics different from that associated with local file systems.

With remote file systems, we must account for situations in which connection is lost to the server. In these cases, we must delay all operations until connection is re-established.

Could you simulate a multilevel directory structure with a single-level directory structure in which arbitrarily long names can be used? If your answer is yes, explain how you can do so, and contrast this scheme with the multilevel directory scheme. How would your answer change if file names were limited to seven characters?

Yes, we can do so by appending the directory name to the file name using the "." character. Starting with the root directory, then the subdirectory than the file name, all separated by ".", we can do this. Unlike a multilevel directory, which does not allow local user to files to be accessed by other users, specifying the complete search path will allow this. This will fail if the length is restricted to 7 characters.

Explain the purpose of the open() and close() operations

open() -called before the file is used - allows for a file to be opened in a specified mode, as permitted by its permissions - operation takes the file name, searches the directory structure, then copies the directory entry into the open file table. - returns a pointer to the entry in the open file table close() - called after a task if completed by a task on the file - decreases the open count for the file on then OFT - when open count is 0, file entry is removed from OFT

Consider a file system that uses inodes to represent files. Disk blocks are 8 KB in size, and a pointer to a disk block requires 4 bytes. This file system has 12 direct disk blocks, as well as single, double, and triple indirect disk blocks. What is the maximum size of a file that can be stored in this file system?

(12 * 8 KB) + (2048 * 8 KB) + (2048 * 2048 * 8 KB) + (2048 * 2048 * 2048 * 8 KB) = 64 terabytes Because the block size is 8KB and a pointer is 4 bytes, the number of pointers contained in a block is 8K / 4 = 2K, namely 2048. So the single indirect block can support 2048 blocks of data, each of which holds 8 KB. The total data supported by the single indirect block is thus 2048*8KB. Similarly, double indirect block supports 2048 'single indirect blocks', so the totally data supported is 2048*2048*8KB.

In Section 5.4, we mentioned that disabling interrupts frequently can affect the system's clock. Explain why this can occur and how such effects can be minimized.

- The system clock is updated at every clock interrupt. - If interrupts were disabled—particularly for a long period of time—it is possible the system clock could easily lose the correct time. - The system clock is also used for scheduling purposes. For example, the time quantum for a process is expressed as a number of clock ticks. At every clock interrupt, the scheduler determines if the time quantum for the currently running process has expired. - If clock interrupts were disabled, the scheduler could not accurately assign time quantums. - This effect can be minimized by disabling clock interrupts for only very short periods

CHAPTER 10 Q19

------------------------------

Give an example of an application that could benefit from operating system support for random access to indexed files.

A database. A file in the database will be searched for the file by a file pointer; if the file is found, it's contents will be fetched.

In some systems, a subdirectory can be read and written by an authorized user, just as ordinary files can be. - what are protection issues? - Suggest a scheme for dealing with each of these protection problems.

A user may attempt to modify an entry in the directory that doesn't reflect a change in the file system as a whole. This includes deleting the entry in directory, but having the file remain in the file-system as hidden. Solution: do not allow user to interact directly with subdirectories, but rather, using system calls that allow the system to maintain uniformity.

Show that, if the wait() and signal() semaphore operations are not executed atomically, then mutual exclusion may be violated.

A wait operation atomically decrements the value associated with a semaphore. If two wait operations are executed on a semaphore when its value is 1, if the two operations are not performed atomically, then it is possible that both operations might proceed to decrement the semaphore value, thereby violating mutual exclusion.

Discuss the advantages and disadvantages of supporting links to files that cross mount points (that is, the file link refers to a file that is stored in a different volume).

Advantage - greater transparency; user doesn't need to be aware of mount points / link creation Disadvantage - file system containing the link may be mounted while the file system containing the target file may not be; resulting in a dead link

Similarly, some systems support many types of structures for a file's data, while others simply support a stream of bytes. What are the advantages and disadvantages of each approach?

Advantage of a system supposing many structures - no need for an application supporting each file structure. The disadvantage of above, increase of the size of the system. The advantage of a system treating file as a stream of bytes, simplicity.

How do caches help improve performance? Why do systems not use more or larger caches if they are so useful?

Allow components of differing speeds to communicate with each other more efficiently by storing the data from the slower device in the faster device. Increasing amount of caches/ size of the cache inherently makes systems more expensive.

Some systems automatically open a file when it is referenced for the first time and close the file when the job terminates. Discuss the advantages and disadvantages of this scheme compared with the more traditional one, where the user has to open and close the file explicitly.

Automatic opening/closing relieves the user from having to invoke open/close operations; requires more overhead

Contrast the performance of the three techniques for allocating disk blocks (contiguous, linked, and indexed) for both sequential and random file access.

Contiguous - Sequential - Efficient, file is stored contiguously, and thus can easily be accessed sequentially. Contiguous - Random - Works very well as you can EASILY DETERMINE THE ADJACENT DISK BLOCK containing the position you wish to seek to. ---------- Linked - sequential - Decent; following blocks from one block to the next Linked - random - Poor as it may require following the links to several disk blocks until you arrive at the intended seek point of the file. ----------- Indexed - seq - Works well as sequential access simply involves sequentially accessing each index Indexed - random - Works well as it is easy to determine the index associated with the disk block containing the position you wish to seek to

Consider a system that supports 5,000 users. Suppose that you want to allow 4,990 of these users to be able to access one file. - How would you specify this protection scheme in UNIX? - Can you suggest another protection scheme that can be used more effectively for this purpose than the scheme provided by UNIX?

Create a group containing all 4990 users then allow them access to the file. Alternate suggestion: create a no access table containing the 10 users, which in turn creates a smaller list than the one holding 4990 users.

Some systems automatically delete all user files when a user logs off or a job terminates, unless the user explicitly requests that they be kept. Other systems keep all files unless the user explicitly deletes them. Discuss the relative merits of each approach.

Deletion at log off saves disk space. Keeping until specified ensures that no wanted files are accidently deleted.

If the operating system knew that a certain application was going to access file data in a sequential manner, how could it exploit this information to improve performance?

File system could prefetch the consequent blocks in suspicion of future requests to these blocks. This prefetching would reduce the hold up time experienced by the process for future requests.

Is it possible to have a deadlock involving only a single process? Explain your answer

For deadlock, 4 conditions must hold: 1. mutual exclusion 2. hold-and-wait 3. no pre-emption 4. circular wait with a single process, circular wait cannot occur; circular wait occurs when one process is waiting for the resources of another process - cannot occur when there is only one process

Consider a system that supports the strategies of contiguous, linked, and indexed allocation. What criteria should be used in deciding which strategy is best utilized for a particular file?

If a file size is small, choose contiguous allocation. Contiguous allocation has issues as file size grows; there is no guarantee the next contiguous block may be free. If file size is large, choose linked allocation. When random access is necessary, and a large amount of disk space is needed, use indexed allocation.

What problems could occur if a system allowed a file system to be mounted simultaneously at more than one location?

If a file system were mounted at more than one location, there would be multiple paths that lead to a file. When the file is deleted, all paths are also deleted.

What are the advantages and disadvantages of providing mandatory locks instead of advisory locks whose use is left to users' discretion?

If a lock is mandatory, then once another process acquires an exclusive lock, the OS will prevent any other process from accessing the file. This is carried out by the OS. If a lock is advisory, it is left to the developer to ensure locks are carried out properly.

Consider a file system in which a file can be deleted and its disk space reclaimed while links to that file still exist. What problems may occur if a new file is created in the same storage area or with the same absolute path name? How can these problems be avoided?

If two users create two files of the same name, and one wishes to open one of the files, the first file found on the VTOC of the disk will be opened. These problems can be avoided by keeping track of all links to a file, and deleting the link when the file itself is deleted.

Why must the bit map for file allocation be kept on mass storage, rather than in main memory?

In case of system crash (memory failure) the free-space list would not be lost as it would be if the bit map had been stored in main memory..

Why do some systems keep track of the type of a file, while others leave it to the user and others simply do not implement multiple file types? Which system is "better"?

In some systems, operations on files are based on their file types. In some systems, operations on files are determined data interpretation by the process. The better of the two is based on user/ process needs.

Some file systems allow disk storage to be allocated at different levels of granularity. For instance, a file system could allocate 4 KB of disk space as a single 4-KB block or as eight 512-byte blocks. How could we take advantage of this flexibility to improve performance? What modifications would have to be made to the free-space management scheme in order to support this feature?

Internal fragmentation is reduced. In addition to maintaining a bitmap of free blocks, one would also have to maintain extra state regarding which of the subblocks are currently being used inside a block. The allocator would then have to examine this extra state to allocate subblocks and coalesce the subblocks to obtain the larger block when all of the subblocks become free.

Consider a file system on a disk that has both logical and physical block sizes of 512 bytes. a - How is the logical-to-physical address mapping accomplished in this system? (For the indexed allocation, assume that a file is always less than 512 blocks long.) b - If we are currently at logical block 10 (the last block accessed was block 10) and want to access logical block 4, how many physical blocks must be read from the disk?

Let Z be the logical block 4 (block number). Contiguous - Divide the logical address by 512 with X and Y the resulting quotient and remainder respectively. a. Add X to Z to obtain the physical block number. Y is the displacement into that block. b. 1 Linked - Divide the logical address by 511 with X and Y the resulting quotient and remainder respectively. a. Chase down the linked list (getting X + 1 blocks). Y + 1 is the displacement into the last physical block. b. 4 In this case, we must read physical block number Z first to get the first 511 bytes, which we do not care, and a pointer to the next block, say, number Z1. Then we read block Z1 to find the physical number of the third block. Then we read the third block just to find the physical number of the fourth block, which is what we actually need. Then we need to read the fourth time to get the actual data. Indexed - a. Get the index block into memory. Physical block address is contained in the index block at location X. Y is the displacement into the desired physical block. b. 2

Compare this implementation of a file with the standard contiguous and linked implementations.

More overhead than the contiguous allocation, less overhead than linked allocation.

CHAPTER 11 Q1

OMITTED

List three examples of deadlocks that are not related to a computersystem environment.

Person going down ladder while another going up.

What are the advantages of the variant of linked allocation that uses a FAT to chain together the blocks of a file?

Random access time is improved; the disk head can find location of any block by checking information in the FAT

Fragmentation on a storage device can be eliminated by recompaction of the information. Typical disk devices do not have relocation or base registers (such as those used when memory is to be compacted), so how can we relocate files? Give three reasons why recompacting and relocation of files are often avoided.

Relocation of files on secondary storage involves considerable overhead—data blocks have to be read into main memory and written back out to their new locations. Furthermore, relocation registers apply only to sequential files, and many disk files are not sequential. For this same reason, many new files will not require contiguous disk space; even sequential files can be allocated noncontiguous blocks if links between logically sequential blocks are maintained by the disk system.

Provide examples of applications that access files according to the following methods: - Sequential - Random

Sequential: Applications that access documents SUCCESSIVELY - word processors, video players, music players and web administrations. Random: Applications that access documents ARBITRARILY - databases, video and sound editors.

Explain why spinlocks are not appropriate for single-processor systems yet are often used in multiprocessor systems.

Spinlock is another word for busy waiting (2pts). In a single processor system, it possible to protect critical regions by simply turning off (disabling) interrupts, and this is more efficient than spinlocks, cutting down on context switching. (4pts) In a multiprocessor system, it's difficult to coordinate all the processors turning off interrupts at the same time, so spinlocks are a reasonable alternative (4pts)

Illustrate how a binary semaphore can be used to implement mutual exclusion among n processes.

The n processes share a semaphore, mutex, initialized to 1. Each process Pi is organized as follows: do { wait(mutex); /* critical section */ signal(mutex); /* remainder section */ } while (true);

The open-file table is used to maintain information about files that are currently open. Should the operating system maintain a separate table for each user or maintain just one table that contains references to files that are currently being accessed by all users? If the same file is being accessed by two different programs or users, should there be separate entries in the open-file table? Explain.

The operating system should maintain just one table that contains all references to files being accessed. Why? The OFT contains references to all open files being accessed by any number of users and any number of processes. When all processes are done with the file, only then is it removed from the OFT. Yes there should be separate entries in the OFT, when no more entries are associated with a file being open, we can then close the file.

Discuss how performance optimizations for file systems might result in difficulties in maintaining the consistency of the systems in the event of computer crashes.

The primary difficulty that might arise is due to delayed updates of data and metadata. Updates could be delayed in the hope that the same data might be updated in the future or that the updated data might be temporary and might be deleted in the near future. However, if the system were to crash without having committed the delayed updates, then the consistency of the file system is destroyed.


Conjuntos de estudio relacionados

Chapter 13 Leadership Effectiveness New Perspectives

View Set

Chemistry regents exam practice questions

View Set

Law - Chapter 11: Employment, data protection, and intellectual property law

View Set

Chapter 13: Viruses, Viroids, and Prions

View Set

Ch.3 Factors Affecting Premiums, Rating of Life Insurance and Selection Criteria

View Set

NUR 1050 Fundamentals II CH 40 Fluid, Electrolyte, & Acid base balance

View Set

AINS 101 - Increasing Your Insurance IQ

View Set

Unit 6: Industrialization and Economic Development

View Set