Пример #1
0
extern void kthread_init_runqueue(kthread_runqueue_t *kthread_runq)
{
	kthread_runq->active_runq = &(kthread_runq->runqueues[0]);
	kthread_runq->expires_runq = &(kthread_runq->runqueues[1]);

	gt_spinlock_init(&(kthread_runq->kthread_runqlock));
	init_runqueue(kthread_runq->active_runq);
	init_runqueue(kthread_runq->expires_runq);

	TAILQ_INIT(&(kthread_runq->zombie_uthreads));
	return;
}
Пример #2
0
Файл: sched.c Проект: ferreiro/C
/*
 * Initialize global scheduling structures
 */
static void sched_init(struct sched_class* sc)
{
    int cpu=0;
    char logfile_name[10]="";

    for (cpu=0; cpu<nr_cpus; cpu++) {
        init_runqueue(&runqueues[cpu],cpu);
        init_slist(&sched_events[cpu],offsetof(sched_event_t,links));
    }

    active_sched_class=sc;

    /* Perform class-specific global initialization if required */
    if (active_sched_class->sched_init && active_sched_class->sched_init()) {
        perror("Couldn't initialize scheduling class");
        exit(1);
    }

    if( pthread_mutex_init(&simulation_lock,NULL) < 0) {
        perror("Can't create mutex");
        exit(1);
    }

    if( sys_barrier_init(&simulation_barrier,nr_cpus) < 0) {
        fprintf(stderr,"Can't create barrier");
        exit(1);
    }

    /* Open log files */
    /* NULL initialization */
    memset(cpu_log,0,MAX_CPUS*sizeof(FILE*));

    /* Delete existing files*/
    system("rm -f CPU_*.log");

    for (cpu=0; cpu<nr_cpus; cpu++) {

        sprintf(logfile_name,"CPU_%i.log",cpu);

        if((cpu_log[cpu] = fopen(logfile_name, "w")) == NULL) {
            fprintf(stderr,"Can't open file \n");
            sched_terminate(1);
        }
        setbuf(cpu_log[cpu],NULL);
    }

    setbuf(stdout,NULL);

}
Пример #3
0
int main()
{
	runqueue_t *active_runq, *expires_runq;
	uthread_struct_t *u_obj;
	int inx;

	active_runq = &active_runqueue;
	expires_runq = &expires_runqueue;

	init_runqueue(active_runq);
	init_runqueue(expires_runq);

	fill_runq(active_runq);
	print_runq_stats(active_runq, "ACTIVE");
	print_runq_stats(expires_runq, "EXPIRES");
	change_runq(active_runq, expires_runq);
	print_runq_stats(active_runq, "ACTIVE");
	print_runq_stats(expires_runq, "EXPIRES");
	empty_runq(expires_runq);
	print_runq_stats(active_runq, "ACTIVE");
	print_runq_stats(expires_runq, "EXPIRES");
	
	return 0;
}