proc: Add getcount() systemcall

This patch adds information to the core process structures for enabling
the getcount() systemcall. This systemcall when passed a valid
systemcall number as an argument, will return the number of times the
referenced systemcall was invoked by the calling process.
This commit is contained in:
Sanchayan Maity 2015-03-16 23:32:07 +05:30
parent 83a632b1b2
commit bcef224332
2 changed files with 7 additions and 0 deletions

5
proc.c
View file

@ -36,6 +36,7 @@ allocproc(void)
{
struct proc *p;
char *sp;
int i;
acquire(&ptable.lock);
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
@ -70,6 +71,10 @@ found:
memset(p->context, 0, sizeof *p->context);
p->context->eip = (uint)forkret;
// Initialise the syscall count array entries with 0
for (i = 0; i < NO_OF_SYSCALLS; i++)
p->syscall_count[i] = 0;
return p;
}

2
proc.h
View file

@ -1,5 +1,6 @@
// Segments in proc->gdt.
#define NSEGS 7
#define NO_OF_SYSCALLS 22
// Per-CPU state
struct cpu {
@ -66,6 +67,7 @@ struct proc {
struct file *ofile[NOFILE]; // Open files
struct inode *cwd; // Current directory
char name[16]; // Process name (debugging)
uint syscall_count[NO_OF_SYSCALLS]; // Number of particular syscalls
};
// Process memory is laid out contiguously, low addresses first: