void biasWheel::electCouple(couple *c) { void *a,*b; int ia,ib; double pa,pb; elect(&a,&pa,&ia); elect(&b,&pb,&ib); while(b==a) { elect(&b,&pb,&ib); } c->A = a; c->iA = ia; c->pA = pa; c->B = b; c->iB = ib; c->pB = pb; }
/* *** External visible functions *** */ void elect() { // Delete current if terminated (so a terminated process does not wait at the end of list) if (current_process->status == TERMINATED) { terminate_if_last_process(); current_process->previous->next = current_process->next; current_process->next->previous = current_process->previous; struct pcb_s* process_to_delete = current_process; choose_next_process(); free_process(process_to_delete); } else if (current_process->status == BLOCKED) { choose_next_process(); } else { current_process->status = READY; choose_next_process(); } #if DEBUG #if FB fb_print_char('\n'); fb_print_text("The process with PID "); fb_print_int(current_process->pid); fb_print_text(" chosen with priority "); fb_print_int(current_process->priority); fb_print_char('\n'); #else log_str("\n The process with PID "); log_int(current_process->pid); log_str(" chosen with priority "); log_int(current_process->priority); log_str("\n"); #endif #endif if (current_process->status == TERMINATED || current_process->status == BLOCKED) elect(); // Elect the next one, and delete the current one else current_process->status = RUNNING; // Else, this one is now running }
void mdEl(elector *p){ elector *t=p; long int x; printf("Dame tu cedula \n:"); scanf("%li",&x); while (t){ if (x==t->ci){ printf("HOLA"); elect(&t); break; } t=t->prox; } }
void cheak()//学生选课子函数(查询可选课程) { char e; struct couse * c; struct student * s; int num2,i,j=0,t=0; printf("请输入你的学号:"); scanf("%d",&num2); s=head2; while(s->num2!=num2 && s->next!=NULL) s=s->next; if(s->num2!=num2) { printf("不存在你的信息,请进入主菜单录入你的信息!\n"); goto end; } c=head1; printf("你的可选课程编号:\n"); while(c!=NULL) { for(t=0,i=0;s->nelenum[i]!=0;i++) { if(c->num1==s->nelenum[i]) t=1; } if(t==0 && (c->nelepeo!=c->Melepeo)) { printf("%d\n",c->num1); j++; } c=c->next; } if(j==0) { printf("你已选完所有课程,无法再多选!\n"); goto end; } printf("选课(y/n)?:\n"); getchar(); e=getchar(); i=0; while(e=='y') { elect(s); printf("继续选课(y/n)?:\n"); getchar(); e=getchar(); } end:; }