Skip to content

Commit

Permalink
proc name included
Browse files Browse the repository at this point in the history
  • Loading branch information
Rwik2000 committed Nov 13, 2020
1 parent 43a2e92 commit cbb6e80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ mlfq(struct proc **q_current,struct proc **q_next,int *current, int *next,struct
pstat_var.pid[i] = p->pid;
pstat_var.priority[i] = p->priority;
pstat_var.state[i] = p->state;
safestrcpy(pstat_var.name[i],p->name, sizeof(p->name));
int j;
for(j = 0; j < 4; ++j){
pstat_var.ticks[i][j] = p->myticks[j];
Expand Down Expand Up @@ -746,21 +747,21 @@ int
getpinfo(struct pstat* pstat_xyz)
{

cprintf("pid \t state \t\t priority \t\t ticks \n");
cprintf("pid \t name \t\t state \t\t priority \t\t ticks \n");
for(int i=0;i<NPROC;i++){
if(pstat_var.inuse[i] == 1){
if(pstat_var.state[i] == SLEEPING)
cprintf("%d \t SLEEPING \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);
cprintf("%d \t %s \t\tSLEEPING \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.name[i], pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);
else if(pstat_var.state[i] == RUNNING)
cprintf("%d \t RUNNING \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);
cprintf("%d \t %s \t\tRUNNING \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.name[i], pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);
else if(pstat_var.state[i] == RUNNABLE)
cprintf("%d \t RUNNABLE \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);
cprintf("%d \t %s \t\tRUNNABLE \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.name[i], pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);
else if(pstat_var.state[i] == ZOMBIE)
cprintf("%d \t ZOMBIE \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);
cprintf("%d \t %s \t\tZOMBIE \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.name[i], pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);
else if(pstat_var.state[i] == UNUSED)
cprintf("%d \t UNUSED \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);
cprintf("%d \t %s \t\tUNUSED \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.name[i], pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);
else if(pstat_var.state[i] == EMBRYO)
cprintf("%d \t EMBRYO \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);
cprintf("%d \t %s \t\t EMBRYO \t\t %d \t\t %d \n",pstat_var.pid[i],pstat_var.name[i], pstat_var.priority[i],pstat_var.ticks[i][pstat_var.priority[i]]);

}
}
Expand Down
1 change: 1 addition & 0 deletions proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct pstat{
int priority[NPROC]; // current priority level of each process (0-3)
enum procstate state[NPROC]; // current state (e.g., SLEEPING or RUNNABLE) of each process
int ticks[NPROC][4]; // number of ticks each process has accumulated at each of 4 priorities
char name[NPROC][16]; // Name of the process
};
/*Global Definition of queues and pointers to queues sizes*/
// extern struct proc *q_0[64];
Expand Down

0 comments on commit cbb6e80

Please sign in to comment.