Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The first system call you'll add is one we'll name getcount, which, when passed a valid system call number (listed in the file syscall.h) as

image text in transcribed

The first system call you'll add is one we'll name getcount, which, when passed a valid system call number (listed in the file "syscall.h") as an argument, will return the number of times the referenced system call was invoked by the calling process E.g., the following test program #include #include #include "types.h" "user"h" "syscall,h" int main (int argc, char *argv]) printf(1, "initial if (fork()0) printf(1, printf(1, fork count %d ", getcount (SYS-fork)); "child "child fork count %d ", getcount (SYS-fork)); write count %d ", getcount(SYS-write)); else t wait); printf(1, printf(1, "parent "parent fork count %d ", getcount(SYS-fork)); write count %d ", getcount (SYS-write)); printf(1, exit); "wait count %d ", getcount (SYS-wait)); should produce the following output (note that each character is output with a separate call to write in xv6): initial fork count child fork count 0 child write count 19 wait count parent fork count 1 parent write count 41 wait count l Hints You will need to modify a number of different files for this exercise, though the total number of lines of code you'll be adding is quite small. At a minimum, you'll need to alter syscall.h, syscall.c, user.h, and usys. S to implement your new system call (try tracing how some other system call is implemented, e.g., uptime, for clues). You will likely also need to update struct proc, located in proc.h, to add a syscall-count tracking data structure for each process. To re-initialize your data structure when a process terminates, you may want to look into the functions found in proc.c Chapter 3 of the xv6 book contains details on traps and system calls (though most of the low level details won't be necessary for you to complete this exercise) The first system call you'll add is one we'll name getcount, which, when passed a valid system call number (listed in the file "syscall.h") as an argument, will return the number of times the referenced system call was invoked by the calling process E.g., the following test program #include #include #include "types.h" "user"h" "syscall,h" int main (int argc, char *argv]) printf(1, "initial if (fork()0) printf(1, printf(1, fork count %d ", getcount (SYS-fork)); "child "child fork count %d ", getcount (SYS-fork)); write count %d ", getcount(SYS-write)); else t wait); printf(1, printf(1, "parent "parent fork count %d ", getcount(SYS-fork)); write count %d ", getcount (SYS-write)); printf(1, exit); "wait count %d ", getcount (SYS-wait)); should produce the following output (note that each character is output with a separate call to write in xv6): initial fork count child fork count 0 child write count 19 wait count parent fork count 1 parent write count 41 wait count l Hints You will need to modify a number of different files for this exercise, though the total number of lines of code you'll be adding is quite small. At a minimum, you'll need to alter syscall.h, syscall.c, user.h, and usys. S to implement your new system call (try tracing how some other system call is implemented, e.g., uptime, for clues). You will likely also need to update struct proc, located in proc.h, to add a syscall-count tracking data structure for each process. To re-initialize your data structure when a process terminates, you may want to look into the functions found in proc.c Chapter 3 of the xv6 book contains details on traps and system calls (though most of the low level details won't be necessary for you to complete this exercise)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

What roles have these individuals played in your life?

Answered: 1 week ago

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago