1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
   | #include <stdio.h>
#include "processus.h"
#include "scheduler.h"
 
int x = 0;
 
void foo (void *p) {
    int dep = *(int *)p;
    int i;
    for (i=dep; i<10; i++) {
        if((x+i)<12)
            printf("%d\n",i);
        proc_commuter();
    }
}
 
void bar (void *unused) {
    while (x<50) {
        x++;
        proc_commuter();
    }
}
 
int main () {
    processus_t p1, p2, p3;
    int dep1, dep2;
    /*sched_set_scheduler(&sched_prio_tempsreel); */
    proc_init();
    dep1 = 0;
    p1 = proc_activer("P1", foo, &dep1);
    dep2 = 6;
    p2 = proc_activer("P2", foo, &dep2);
    p3 = proc_activer("P3", bar, NULL);
    sched_set_priority_other(p1,3);
    sched_set_priority_other(p2,2);
    sched_set_priority_other(p3,3);
    proc_suspendre();
} | 
Partager