What is the difference between symbolic and hard links to


Operating Systems Assignment

1. What is the difference between symbolic and hard links to files? On the os server, What happens when you try to create a symbolic link in /temp to a file that is in your home directory? How about a hard link? Explain what happens.

2. A UNIX file system has 4096-byte blocks (this is typical) and 4-byte disk addresses. What is the maximum file size if i-nodes contain 100 direct entries, and one single and one double indirect entry? What happens when you add one triple indirect entry?

3. Using the stat utility on the os server, what can you say about how renaming a file differs from copying a file and deleting the old one, and how copying a file to a different directory differs from moving the file there?

4. One way to use contiguous allocation of the disk and not suffer from holes is to compact the disk every time a file is removed. Since all files are contiguous, copying a file requires a seek and rotational delay to read the file, followed by the transfer at full speed. Writing the file back requires the same work. Assume you have a modern disk with an average seek time of 15 msec, operates at 7200RPM, and has a transfer rate of 6 Gbps. If the average file size is 16 KB, how long does it take to read a file into main memory and write it back to a new location? (Assume no prefetching and cold caches.) How long would it take to compact half of a 2 TB disk?

5. How many disk operations are needed to fetch the i-node for the file /dir1/dir2/dir3/myfile? Assume that the i-node for the root directory is in memory, but nothing else along the path is in memory. Also assume that all directories fit in one disk block.

6.

(a) Write a C program that reverses the bytes of a given arbitrary length file and outputs them to another specified file, which should be overwritten if it already exists. So, invoking your program as follows

./reverse infile outfile

will result in the first byte of outfile being the last byte of infile, and so on until the last byte of outfile is the first byte of infile. The given filenames are just an example, make your own infile. You must use fseek()/fread()/fwrite().

(b) Write another C program that reverses the bytes of a given arbitrary length file in-place, as in, the contents of the file are swapped without a temporary file and without producing a second file. Use mmap(). E.g. ./reverse2 infile results in the contents of infile being reversed after the call, and calling ./reverse2 infile twice should result in the same file as you started with.

(c) Compare the performance of ./reverse with ./reverse2. Use the timing function below to target your timing to just the portion of the program which actually does the reversing and produces output. Get the averages of a bunch of runs.

#include #include #include

// you may use this to convert the contents of the timeval struct to ns long nanosec(struct timeval t){
return((t.tv_sec*1000000+t.tv_usec)*1000);
}

int main(){ int res;
struct timeval t1, t2;

res=gettimeofday(&t1,NULL); assert(res==0);
//stuff you want to measure might go here res=gettimeofday(&t2,NULL); assert(res==0);
//find average time here
}

7. Write a wc utility that takes in a single filename as an argument, and computes the number of characters, words, and lines present in that file. Now, have this wc store the name of the input file, and numbers of characters, words, and lines in a binary file (put all the information you're going to save into a struct, then write that struct out to a file); call the file wc.saved. Each time this wc is invoked from the command line, and only if the input file exists and is readable, use explicit file I/O to add the file's information to wc.saved if that file's information is not already present in wc.saved. If information about the file already exists use mmap to edit its entry to reflect the latest counts. Add a -p option to your program so that invoking wc -p prints all the collected data out of wc.saved (reasonably formatted, of course).

Solution Preview :

Prepared by a verified Expert
Operating System: What is the difference between symbolic and hard links to
Reference No:- TGS02505216

Now Priced at $40 (50% Discount)

Recommended (94%)

Rated (4.6/5)