8 - The UNIX System Interface
Exercise 8-1
Rewrite the program cat from Chapter 7 using
read
,write
,open
andclose
instead 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
fopen
and_fillbuf
with 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
lseek
except thatfp
is a file pointer instead of a file descriptor and the return value is anint
status, not a position. Writefseek
. Make sure that yourfseek
coordinates properly with the buffering done for the other functions of the library. [1]
My solution
tbd
Official solution
tbd
Exercise 8-5
Modify the
fsize
program 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 ton
objects of sizesize
, with the storage initialized to zero. Writecalloc
, by callingmalloc
or by modifying it. [1]
My solution
tbd
Official solution
tbd
Exercise 8-7
malloc
accepts a size request without checking its plausibility;free
believes 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 blockp
ofn
characters into the free list maintained bymalloc
andfree
. 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