EDIT:
GOT IT
here is what I did:
in syscall.c:
extern int numSysCalls;
in sysproc.c:
int numSysCalls = -1;
Okay, so I'm working on implementing an easy system call that returns the number of times a system call has been made. Seems easy, but I'm getting an error I don't understand...
Basically, here is what I did: in syscall.c there is a function called syscall() that checks whether it is a syscall or not. I have basically declared a variable and am incrementing it every time this function is called.
Var Declaration in syscall.c:
18: int16_t numSysCalls = -1; //global
Syscall() function:
115: void syscall(void){
116: numSysCalls++;
...
Error I'm getting:
kernel/syscall.c:116: error: ‘numSysCalls’ undeclared (first use in this function)
kernel/syscall.c:116: error: (Each undeclared identifier is reported only once
kernel/syscall.c:116: error: for each function it appears in.)
Then, in sysproc.c, I have the same extern int and simply return the int when I call my function numCalls, as follows:
Extern Variable in sysproc.c:
extern int numSysCalls;
Method in question:
int sys_numSys(void){
if (numSysCalls == -1) return numSysCalls;
else return numSysCalls + 1;
}
In summary: numSysCalls should be incremented whenever a syscall (of any kind) is called - successful or not.
numSys only returns the number, or -1 if error.