main(); { stack * a = arraystack(); stack * b = liststack(); int i; for (i = 1; i < 10; i++) (*a->push)( a, i ); for (i = 1; i < 10; i++) (*b->push)( b, (*a->pop)( a ) ); for (i = 1; i < 10; i++) printf( "%d\n", (*b->pop)( b ) ); }Note that the only methods are push and pop, and note that no checking for stack over and underflow is needed! The focus of this exercise is on the basic question of how polymorphic objects are implemented in non object-oriented languages.
The problem: Describe how to compute the optimal disk sector size, that is, the sector size that will balance the system, given that the CPU can compute N bytes per second of data that must be read or written to the disk, given that the average latency time (seek plus rotation) on the disk is L seconds per I/O transfer, and given that the disk data transfer rate is T bytes per second once the transfer actually begins.
Note that L and T are easily measured for any disk system, but that, while N depends on the CPU clock speed, it also depends on the type of computation being performed, and therefore, on the mix of programs!
Note: B-trees are a well-known data structure for maintaining balanced trees with between N and 2N pointers per node. They are not the same as binary trees! You may want to review B-trees in a good data structures textbook.
The low-level file system on the XDFS was quite simple: All sectors on the disk were either index sectors in the B-tree or they were data sectors in some file.
The Problem, part A: From the user perspective, how does the XDFS low-level file system differ from the UNIX low level file system? Recall that the UNIX low level file system uses I-numbers to reference Inodes that describe files.
The Problem, part B: What performance benefits and what performance penalties would you expect in a system that changes from the UNIX approach to the XDFS approach. Would one or the other approach deliver better performance for access to some class of file or another?
The Problem: The XDFS system also set aside sector 0 of each file to hold the information needed to reconstruct the directory structure on the disk in the event that the directory was corrupted by a disk failure. What information needs to be saved in sector zero of each pair to do this? Assume a simple hierarchical tree-structured directory with no access rights or other extraneous material, where each directory is itself a file of pairs that relate textual file names to the corresponding file numbers. Assume that textual file names are always shorter than the sector size.
Resources | assignment | gradebook | exam-file | ------+------------+-----------+-----------+--- Instructor | R | R/W | R/W | ------+------------+-----------+-----------+--- Users TA | R | R/W | --- | ------+------------+-----------+-----------+--- Typical Student | R/W | --- | --- | ------+------------+-----------+-----------+--- Another User | --- | --- | --- | ------+------------+-----------+-----------+---The problem: Given that UNIX supports a quirky special case of access control lists, where each user is a member of a group, and access control lists for files grant access to an individual, one group and the public, how can the access rights in the above matrix be enforced on a UNIX system. The variables you can control are the group memberships, ownership of each file, group of each file, and the access rights on each file's UNIX-style ACL.
You may want to study the chmod (1), chown (8), and chgrp (1) UNIX commands, as well as the format of the group file (5). Parenthesized numbers refer to traditional sections of the Unix Programmer's Reference Manual (as in the man command).