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; struct proc *p;
char *sp; char *sp;
int i;
acquire(&ptable.lock); acquire(&ptable.lock);
for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++)
@ -70,6 +71,10 @@ found:
memset(p->context, 0, sizeof *p->context); memset(p->context, 0, sizeof *p->context);
p->context->eip = (uint)forkret; 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; return p;
} }

2
proc.h
View file

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