Homework 1

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Student name : Vo Tan Phuoc Student ID : 08520299 Class : AEP-01 SOLUTION FOR HOMEWORK 1 2.

2b: int fseek ( FILE * stream , long offset , int origin ); Where: Stream: Pointer to an open file. Offset: Number of bytes from origin. Origin: Initial position from where offset is applied. It can be any of these constants defined in stdio.h: SEEK_SET: Beginning of file SEEK_CUR: Current position of the file pointer SEEK_END: End of file 2.2c: Give user read and write permission (4+2), group execute permission (1), others-no permission (0).So command is chmod 610 myfile 2.3: There will be some problems such as: the files that were not automatically closed will become inaccessible to other programs. Another problem is that some information was hold in buffers might be missing.

2.6: - The ls send a list of file names to stdout. - The '|' pipes the list of file names to wc; that is, it provides the list of names as input to wc. - The -w option causes wc to count only the words in its input file, hence counting the number of file names.

3.6: If the disk drive uses 512-byte sectors, the system must write 512 bytes at a time to disk. If the contents of the sector into which the 128byte record is to be stored are not already in memory, there is no way of knowing what the other 384 bytes in the sector are. They must be read in and included with the 128-byte record before being sent to the disk. If processing is sequential, one simple way to decrease the number of reads required would be to process several records as a group before each output operation. Then at most one read would be required for each sector to be output. 3.8: When we access a file, we first access the files inode. Then we access the file itself. If the inode and the file itself are in the same cylinder group, only a short seek is required between the inode access and the file access. In early UNIX systems, we may have to incur a long seek between opening the file and accessing its data. The same problem occurs when we close a file.

Additional Problems 2/ Sector is the smallest storage unit that is addressable by a hard drive, and all information stored by the hard drive is recorded in sectors. Track is the thin concentric circular strips of sectors. At least one head is required to read a single track. Cylinder comprises the same track number on each platter, spanning all such tracks across each platter surface that is able to store data. Platter is the circular disk on which the magnetic data is stored. 4/ a) The capacity of this drive is about 700 MB.

6/ a) 11000 0000 b) 11010 1011 c) 01111 1111 d) 00000 0011

7/ a) We have: pp1p100 Parity bit 1 checks: 1, 3, 5, 7 Parity bit 2 checks: 2, 3, 6, 7 Parity bit 4 checks: 4, 5, 6, 7 So the result is: 0111100 b) We have: pp1p011p101 Parity bit 1 checks: 1, 3, 5, 7, 9, 11 Parity bit 2 checks: 2, 3, 6, 7, 10, 11 Parity bit 4 checks: 4, 5, 6, 7 Parity bit 8 checks: 8, 9, 10, 11 So the result is: 01100110101 c) We have: pp1p001p00111 Parity bit 1 checks: 1, 3, 5, 7, 9, 11, 13 Parity bit 2 checks: 2, 3, 6, 7, 10, 11 Parity bit 4 checks: 4, 5, 6, 7, 12, 13 Parity bit 8 checks: 8, 9, 10, 11, 12 ,13 So the result is: 0111001100111

You might also like