Enter your email address & Win:

System Software Lab Programs ( UNIX Programs ) – 5b

// June 5th, 2009 // Educational, Engineering, Unix and System Software Lab // Written by

Subject : System Software Laboratory

Branch : Information Science & Engineering

Semester : 6

University : VTU

[Click Here to get other programs by email ]

………………………………………………………………………………………………………………………….
PART -B

………………………………………………………………………………………………………………………….

5b) C program that accepts one command-line argument, executes the arguments as a shell command, determines the time taken by it and prints the time values, Use the “times”, function and the “tms” structure. The code need not include error checking.

#include<stdio.h>
#include<sys/times.h>
#include<unistd.h>

int main(int argc,char *argv[10])
{
char cmd[10];
struct tms obj1,obj2;
clock_t st,end;
float time;
st=times(&obj1);
system(“clear”);
printf(“%S\n”,argv[1]);
end=times(&obj2);
printf(“Real time taken = %f\n”,st);
printf(“User time taken = %f\n”,end);
time=(end-st)/3600;
printf(“\nSystem time taken : %f”,time);
return 0;
}

[Click Here to get other programs by email ]

If you enjoyed this post, make sure you subscribe to my RSS feed!

Get Adobe Flash playerPlugin by wpburn.com wordpress themes