15.) Suppose a program has successfully opened a file object, fp, for reading a
ID: 3699576 • Letter: 1
Question
15.) Suppose a program has successfully opened a file object, fp, for reading a file from a disk drive and the program has created a buffer, my-but, of an appropriate size. Consider the following C function call. fread (my_buf, 1, BUFFERSIZE, fp); a) Explain why this function call may, or may not, cause a system call to the operating system. b) Suppose that the above function call causes a system call. Explain why the operating system may, or may not, initiate arn I/O operation to read data from the file on the disk driveExplanation / Answer
a) System call will be happen due to following reason >
read() attempts to read bytes from the file associated with fields into the buffer pointed by buf. Now this read function required access to the file that is mentioned to open. There are many restrictions from OS side. So to communicate with system file system read will make a system call. System calll are used by programs to communicate directly with an operating system.
b)Whenver open a file in c, File will be having a file descriptor to uniquely identifies an open file of the process.
Now operating system will be having a file descriptor table. File descriptor table is the collection of integer array indices that are file descriptors in which elements are pointers to file table entries. One unique file descriptors table is provided in operating system for each process. So to communicate with operating system c uses system call
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.