Hide minor edits - Show changes to markup
Part A: \\
Part B: \\
gcc -o test -I/mnt/Uml/linux-2.4.23/include clockTest.c
gcc -o test -I/mnt/Uml/linux-2.4.23/include clockTest.c
gcc -o test -I/mnt/Uml/linux-2.4.23/include clockTest.c
gcc -o test -I/mnt/Uml/linux-2.4.23/include clockTest.c
and then run the user-space program inside UML.
gcc -o test -I/mnt/Uml/linux-2.4.23/include clockTest.c
gcc -o test -I/mnt/Uml/linux-2.4.23/include clockTest.c
You will learn how to make a system call and about reading/writing user space from the kernel by adding a new function to the kernel. The function itself is trivial---it simply returns the value of "xtime" or using "do_gettimeofday".
A system call is the name of kernel function that is exported for use by user-space programs. For instance, system calls such as gettimofday(), gethostname() are implemented to make the user programs to obtain the time or host name. To learn more, you should read chapter 9 of ULK or Chapter 3.3 and Appendix A of LKP.
Part A:
Design and implement a new kernel function, pedagogictime(), that returns the current system time via a call by reference argument.
If the flag argument is TRUE, then your kernel function should also print the current system time on stdout. Your function should have the following prototype:
int pedagogictime(int flag, struct timeval *current_time);
Your new function should be almost the same as "gettimeofday", though it should ignore the time zone parameter and have the flag to control printing the time to the console. Your function should return TRUE if the function succeeds, and FALSE otherwise.
Part B:
Write a user-space program to test pedagogictime(). The program also should create a stub for your new system call function.
gcc -o test -I/mnt/Uml/linux-2.4.23/include clockTest.c
and then run the user-space program inside UML.
Note: Your user-space program should include a stub of "__syscall2" since pedagogictime takes two arguments. You need "copy_to_user()" function to copy the data from kernel space to user space.
Please submit the following items to your ~/Uml/lab4 directory on elgate: