8 - The UNIX System Interface
Exercise 8-1
Rewrite the program cat from Chapter 7 using
read,write,openandcloseinstead of their standard library equivalents. Perform experiments to determine the relative speeds of the two versions. [1]
My solution
tbd
Official solution
tbd
Exercise 8-2
Rewrite
fopenand_fillbufwith fields instead of explicit bit operations. Compare code size and execution speed. [1]
My solution
tbd
Official solution
tbd
Exercise 8-3
Design and write
_flushbuf,fflush, andfclose. [1]
My solution
tbd
Official solution
tbd
Exercise 8-4
The standard library function
int fseek(FILE *fp, long offset, int origin)is identical to
lseekexcept thatfpis a file pointer instead of a file descriptor and the return value is anintstatus, not a position. Writefseek. Make sure that yourfseekcoordinates properly with the buffering done for the other functions of the library. [1]
My solution
tbd
Official solution
tbd
Exercise 8-5
Modify the
fsizeprogram to print the other information contained in the inode entry. [1]
My solution
tbd
Official solution
tbd
Exercise 8-6
The standard library function
calloc(n, size)returns a pointer tonobjects of sizesize, with the storage initialized to zero. Writecalloc, by callingmallocor by modifying it. [1]
My solution
tbd
Official solution
tbd
Exercise 8-7
mallocaccepts a size request without checking its plausibility;freebelieves that the block it is asked to free contains a valid size field. Improve these routines so they take more pains with error checking. [1]
My solution
tbd
Official solution
tbd
Exercise 8-8
Write a routine
bfree(p, n)that will free an arbitrary blockpofncharacters into the free list maintained bymallocandfree. By usingbfree, a user can add a static or external array to the free list at any time. [1]
My solution
tbd
Official solution
tbd