Uploaded by longnguyenkim2707

baitap

advertisement
1. If FIFO page replacement is used with four page frames and eight pages, how many page
faults will occur with the reference string 0172327103 if the four frames are initially
empty? Now repeat this problem for LRU.
FIFO:
Frames
0
1
3
2
1
1
0
0
0
Page
*
*
fault ?
 6 page faults
7
7
1
0
2
2
7
1
0
3
2
7
1
3
*
*
*
1
7
0
1
0
7
1
0
2
2
7
1
0
3
2
7
1
3
*
*
*
*
*
2
2
7
1
3
7
2
7
1
3
1
2
7
1
3
0
2
7
0
3
*
3
2
7
0
3
2
2
7
1
3
7
2
7
1
3
1
2
7
1
3
0
2
7
1
0
*
3
3
7
1
0
*
LRU:
Frames
3
2
1
0
Page
fault ?
0
 7 page faults
2. A small computer on a smart card has four page frames. At the first clock tick, the R bits are
0111 (page 0 is 0, the rest are 1). At subsequent clock ticks, the values are 1011, 1010, 1101,
0010, 1010, 1100, and 0001. If the aging algorithm is used with an 8-bit counter, give the values
of the four counters after the last tick.
Page 0: 01101110
Page 1: 01001001
Page 2: 00110111
Page 3: 10001011
3.A machine has 48-bit virtual addresses and 32-bit physical addresses. Pages are 8 KB. How
many entries are needed for a single-level linear page table?
4. In many systems, there are “copy”, “delete”, and “move” operations. Why not simply replace
“move” by “copy” then “delete”?
- Efficiency: Performing a "move" operation involves updating the file system metadata to
reflect the new location of the file without actually duplicating the entire content. This operation
is generally faster and consumes fewer system resources compared to copying the entire file.
-
-
-
Atomicity: "Move" operation ensures that the file is either moved completely or not at all.
It maintains the integrity of the file system, as the file is instantly available at the new
location and no partial copies are left behind. On the other hand, a "copy" followed by
"delete" could be interrupted, leaving the system in an inconsistent state with a partially
copied file and potential data loss
Space Optimization: In some cases, a "move" operation may involve only updating the
file's metadata to reflect its new location, without physically moving the entire file
content. This is especially true when the source and destination are on the same storage
device. In contrast, copying the file and then deleting the original would result in
unnecessary duplication of data, consuming more storage space.
File Permissions and Attributes: Moving a file often retains its original permissions,
attributes, and metadata, ensuring consistency in the file's properties. On the other hand,
copying and deleting the file would require explicitly assigning the correct permissions
and attributes to the copied file.
5. Directory structures are typically trees. Name problems that may occur when they
are graphs.
-
-
-
-
Infinite Loops: In a graph-based directory structure, cycles can occur where a directory
or subdirectory references itself or another directory in a loop. This can lead to infinite
loops when navigating or accessing files, causing processes to get stuck in an endless
loop and potentially impacting system performance.
Ambiguity in Path Resolution: When there are multiple paths to reach a specific
directory or file, it can lead to ambiguity in path resolution. Determining the correct path
or resolving conflicts between different paths can become challenging and error-prone,
potentially resulting in incorrect file access or unintended operations.
Redundant or Duplicated Data: Graph-based directory structures can allow multiple
paths to point to the same directory or file. This redundancy can lead to inefficiencies in
storage utilization as well as synchronization issues when modifying or updating the data.
Managing consistency and ensuring proper synchronization across multiple paths can
become complex.
Difficulty in Maintaining Integrity: With a graph-based directory structure, maintaining
the integrity of the directory hierarchy becomes more difficult. The presence of multiple
-
paths and cycles can make it challenging to enforce rules and constraints on the structure,
such as preventing circular references or maintaining a strict parent-child relationship
between directories.
Increased Complexity in File Operations: File operations like copying, moving, or
deleting files can become more complex in a graph-based directory structure. The
existence of multiple paths and cycles requires additional considerations to ensure that
the operations are performed correctly and do not lead to unintended consequences or
data loss.
6. What is the difference between files bar and baz? What happens if we write the
string “abcde” in foo?
The differences between the files "bar" and "baz":
-
-
"bar" is a separate file that was created using the "cp" command, which copies the contents of
"foo" into a new file called "bar."
"baz" is another file that was created by using the command "In foo baz." It seems like there
might be a typo, as the intended command could be "cp foo baz," which would create a copy of
"foo" named "baz."
-Both "bar" and "baz" have the same file size and modification timestamp as "foo" (0 bytes,
created at 13:22 on April 29th).
As for writing the string "abcde" in "foo," the provided information does not indicate any direct action of
writing the string into the file. Therefore, the content of "foo" remains unchanged, still containing 0 bytes.
Download