Question: time.c System Call in xv6: This file is the program what will implement the time system call. This in user space and therefore is written

time.c System Call in xv6:

This file is the program what will implement the time system call. This in user space and therefore is written in C. Implementing the time system requires you to use other xv6 system calls, in particular uptime, fork, exec, and wait. You can find a detailed explanation of these in Chapter 0 of the xv6 textbook.

xv6 time.c system call and linkage

create a new file called time.c, and create a program that will: Accepts arguments from the command line interface. You are expected to do the necessary error checking with the corresponding error message. Fork a child process, the parent process is responsible to measure the time it takes for the child process to finish executing. o Get the current time using uptime. o Fork and then wait for the child process to terminate. o Then when wait returns in the parent process, get the current time again and calculate the difference.

Return an error message if fork is unsuccessful. The child process is responsible for executing the command the user wishes to time using the exec command. You must determine how you will pass the arguments from the command line. o The child is responsible to return an error message is execution fails.

fork() Create process

wait() Wait for a child process to exit

exec(filename, *argv) Load a file and execute it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!