Question: Time system call help xv6. time.c #include types.h #include user.h #include date.h int main (int argc, char *argv[]) { int startTicks = uptime(); int pid

Time system call help xv6.

time.c

#include "types.h" #include "user.h" #include "date.h"

int main (int argc, char *argv[]) { int startTicks = uptime();

int pid = fork(); if (pid < 0) { printf(2, "Error: Invalid PID! "); exit(); } if (pid > 0) wait(); if (pid == 0) { if (exec(argv[1], argv + 1) < 0) { printf(2, "Error: Exec fails! "); exit(); } }

int endTicks = uptime();

int seconds = (endTicks - startTicks); printf(1, " Real Time in ticks: %d tick(s) ", seconds); exit(); }

1. If command is time ls, it should display in number of ticks 2. If command is time ls -s, it should display time in seconds (floating point value).

Just need help modifying this code to fit the requirments of the second inputoption. "time ls -s"

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!