Question: any help please I only want to get same output below how to do it ? thank you Add a new system call called trace

any help please I only want to get same output below how to do it? thank you Add a new system call called trace to xv6. Its syntax is
int trace(int)
When called with a non-zero parameter, e.g., trace(1), system call tracing is
turned on for that process. Each system call from that process will be printed to
the console in a user-friendly format showing:
the process ID
the process name
the system call number
the system call name
Any other processes will not have their system calls printed unless they also call
trace(1).
Calling trace(0) turns tracing off for that process. System calls will no longer be
printed to the console.
In all cases, the trace system call also returns the total number of system calls
that the process has made. Hence, you can write code such as:
printf("total system calls so far =%d
", trace(0));
The system call counting for each system call on a per-process basis. You will
need to keep track of this in the process control block, the proc ################################################### how to get same below output: ...
pid: 2[sh] syscall(5=read)
pid: 2[sh] syscall(5=read)
pid: 2[sh] syscall(1=fork)
pid: 2[sh] syscall(3=wait)
pid: 3[sh] syscall(12=sbrk)
pid: 3[sh] syscall(7=exec)
pid: 3[try] syscall(20=mkdir)
pid: 3[try] syscall(15=open)
pid: 3[try] syscall(16=write)
pid: 3[try] syscall(21=close)
pid: 3[try] syscall(2=exit)
pid: 2[sh] syscall(16=write)
pid: 2[sh] syscall(16=write)
...
syscall.c:
int tracing =0;
void syscall(void){
int num ;
struct proc *curproc = myproc();
num = curproc->tf-> myproc();
if(num cupr[ orcvor;c : my
how to structure.
Write a test program (try.c) to test your trace system call>0&& num < NELEM(syscalls[num]){
cprintf("%s
->%d
", sys_names[num], num);
if(tracing)
cprintf("%d %s: unknown sys call %d %s
", curproc->pid, curporc->nam, sys_names[num]);
cprintf("
");
curproc->tf->eax =syscalls[num]();
}else{
cprintf("%d %s: unknown sys call %d
", curproc->pid, curproc->name, num);
curporc->tf->eax=-1;
}
int sys_my_system_call(void);
}
################################
try.c
#include "types.h"
#include "stat.h"
#include "user.h"
int main(void){
trace(1);
printf(1, "hello");
int no_calls =trace(0);
printf(1, "total system calls so far -%d
", no_calls);
exit()
}

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!