Once you are able to compile the source code and make it run on linksys[XXX] router, you will see "Hello World!" on the terminal. This means, your code compiled correctly and XINU has booted on the router. You are now good to go with any of your code changes. Your task is as follows:
Write a XINU API that takes a process ID 'pid' as argument and prints the process related information using the process table 'proctab' (process.h)
Create a C source file "/system/print_proc_info.c" in the source package. Copy the API template (code snippet) using which new system calls (Kernel API) are developed in XINU. You have to code the logic for printing some process specific information. You should be able to display following info. Note that your API should print the process information only if the pid corresponds to a valid process in the XINU subsystem at that point of time.
1 /* print_proc_info.c - print_proc_info */
2
3 #include < xinu.h >
4 #include < string.h >
5
6 /*------------------------------------------------------------------------
7 * print_proc_info - Prints the info in proctab for a given pid
8 *------------------------------------------------------------------------
9 */
10 syscall print_proc_info(
11 pid32 pid /* process ID */
12 )
13 {
14 intmask mask; /* saved interrupt mask */
15
16 /*----- Declare variables to hold values ------*/
17 /*----- ------------------------------- --------*/
18
19 mask = disable();
20
21 /*----- Your code for fetching process specific info and displaying them goes here -----*/
22 /*----- ------------------------------- --------*/
23 /*----- ------------------------------- --------*/
24
25
26 restore(mask);
27
28 }
29
The API has to return SYSERR if the value of pid is more than the maximum number of processes (NPROC) allowed in XINU or the process corresponding to pid is not a valid process.
For time being, ignore line nos. 19, 26. In brief, whenever you are developing a new system call, and modifying any of kernel/process specific varibles you don't want any other process to preempt and execute. Hence the disable and restore. You can also look at other SYSCALLs for you understanding, for e.g. receive.c , resume.c, etc. Note that the restore is to be executed whenever the system call or API returns even under error conditions.
Inorder to compile "/system/print_proc_info.c", you have to modify the Makerules files. Refer to section (4) below.Here you will write code in system/main.c to test the API which you coded in "Task 1". Note that the macro 'NPROC' in source package denotes the maximum number of processes which can be spawned in XINU system. In main.c you will do following steps in order:
Your API should be well tested. It should return 'SYSERR' if the input pid is not a valid 'pid' existing in XINU subsystem as explained above.
Paste the output from the terminal to a text document. You should be able to identify the newly spwaned process by displaying their process specific information.
Electronic turn-in instructions:
i) go to the xinu-12Spring-lab1-linksys/compile directory and do "make clean".
ii) go to the directory of which your xinu-12Spring-lab1-linksys directory is a subdirectory (NOTE: please do not rename xinu-12Spring-lab1-linksys, or any of its subdirectories.)
e.g., if /homes/jsr/xinu-12Spring-lab1-linksys is your directory structure, goto /homes/jsr
iii) type in the following command
turnin -c cs354 -p lab1 xinu-12Spring-lab1-linksys
You can write code in main.c to test your procedures,
but please note that when we test your programs we will replace the main.c
file! But, submit your code changes in main as part of your submission.
Also, ALL debugging output should be turned off before you submit your code.