int main(void) { int my_pid = getpid(); int parent = getppid(); int rc_get, rc_set; int myrand = rand(); struct module_stat stat_get; struct module_stat stat_set; stat_get.version = sizeof(stat_get); modstat(modfind("getProcessTickets"), &stat_get); get_num = stat_get.data.intval; stat_set.version = sizeof(stat_set); modstat(modfind("setProcessTickets"), &stat_set); set_num = stat_set.data.intval; printf("get_num %d set_num %d \n", get_num, set_num); rc_get = getProcessTickets(my_pid); printf("rc_get before set = %d\n", rc_get); rc_set = setProcessTickets(my_pid, myrand); printf("rc_set = %d (pid = %d)\n", rc_set, myrand); rc_get = getProcessTickets(my_pid); printf("rc_get after set = %d\n", rc_get); return 0; }
int main(int argc, char **argv) { //char *endptr; //int syscall_num; //struct module_stat stat; printf("for each of the desired operations enter the number of the operation as declared below: \n *1 -> set process tickets \n *2 -> get process tickets \n *3 -> set lottery mode \n *4 -> get lottery mode \n"); int input,procId,tickets,lotMode,output; scanf("%d" ,&input); //printf("%d",input); if(input==1) { printf("enter process id please: "); scanf("%d" ,&procId); printf("enter tickets please: "); scanf("%d" ,&tickets); setProcessTickets(procId,tickets); } else if(input==2) { printf("enter process id please: \n"); scanf("%d" ,&procId); getProcessTickets(procId); } else if(input==3) { printf("enter lottery mode please: \n"); scanf("%d",&lotMode); setLotteryMode(lotMode); return 0; } else if(input==4) { getLotteryMode(); } else printf("you haven't entered the correct operation number \n"); return 0; }