Skip to content
Snippets Groups Projects
Commit 865093e8 authored by Lunala's avatar Lunala
Browse files

ajout de commentaire

parent 0ce9bbb7
Branches
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ char key; ...@@ -12,6 +12,7 @@ char key;
void get_keyboard_input_it(int_regs_t *r); void get_keyboard_input_it(int_regs_t *r);
// initialise les variables interne au bon fonctionnemebnt du clavier
void init_keyboard(){ void init_keyboard(){
init_mutex(&keyboard_sem); init_mutex(&keyboard_sem);
......
...@@ -13,6 +13,7 @@ int cpt=0; ...@@ -13,6 +13,7 @@ int cpt=0;
void f_ping(void *args); void f_ping(void *args);
void f_pong(void *args); void f_pong(void *args);
void f_pang(void *args);
void f_keyboard(void *args); void f_keyboard(void *args);
void f_counter(void *args); void f_counter(void *args);
void keyboard_it_queue(int_regs_t *r); void keyboard_it_queue(int_regs_t *r);
...@@ -47,9 +48,12 @@ void main(unsigned int * mboot_info) ...@@ -47,9 +48,12 @@ void main(unsigned int * mboot_info)
puts("\n\n"); puts("\n\n");
puts("\t-> Setting up the keyboard... ");
init_keyboard(); /*** décommenté cette partie si on utilise les IT clavier ***/
puts("OK\n");
// puts("\t-> Setting up the keyboard... ");
// init_keyboard();
// puts("OK\n");
__asm volatile("sti"); __asm volatile("sti");
...@@ -58,8 +62,10 @@ void main(unsigned int * mboot_info) ...@@ -58,8 +62,10 @@ void main(unsigned int * mboot_info)
/*** test sched ***/ /*** test sched ***/
// create_ctx(16384, f_ping, NULL); create_ctx(16384, f_ping, NULL);
// create_ctx(16384, f_pong, NULL); create_ctx(16384, f_pong, NULL);
create_ctx(16384, f_pang, NULL);
start_shed();
/*** test shed + sémaphore***/ /*** test shed + sémaphore***/
...@@ -77,10 +83,10 @@ void main(unsigned int * mboot_info) ...@@ -77,10 +83,10 @@ void main(unsigned int * mboot_info)
/*** test getc ***/ /*** test getc ***/
init_sem(&screen_sem, 1); // init_sem(&screen_sem, 1);
create_ctx(16384, f_getc, NULL); // create_ctx(16384, f_getc, NULL);
create_ctx(16384, f_getc_b, NULL); // create_ctx(16384, f_getc_b, NULL);
start_shed(); // start_shed();
while(1){ while(1){
//print_asciiCode(); //print_asciiCode();
...@@ -199,3 +205,10 @@ void f_pong(void *args){ ...@@ -199,3 +205,10 @@ void f_pong(void *args){
putc('1'); putc('1');
} }
} }
void f_pang(void *args){
while(1){
putc('+');
}
}
...@@ -9,8 +9,6 @@ struct ctx_s * current_ctx = NULL; ...@@ -9,8 +9,6 @@ struct ctx_s * current_ctx = NULL;
struct ctx_s * first_ctx; struct ctx_s * first_ctx;
// on crée la structure contexte avec les champs donnée en paramètre // on crée la structure contexte avec les champs donnée en paramètre
void create_ctx(int stack_size, func_t f, void *args){ void create_ctx(int stack_size, func_t f, void *args){
struct ctx_s * ctx; struct ctx_s * ctx;
...@@ -27,6 +25,7 @@ void create_ctx(int stack_size, func_t f, void *args){ ...@@ -27,6 +25,7 @@ void create_ctx(int stack_size, func_t f, void *args){
} }
current_ctx->next = ctx; current_ctx->next = ctx;
current_ctx = ctx;
} }
...@@ -98,6 +97,9 @@ void switch_to_ctx(struct ctx_s *ctx){ ...@@ -98,6 +97,9 @@ void switch_to_ctx(struct ctx_s *ctx){
void my_yield(){ void my_yield(){
struct ctx_s * ctx = current_ctx->next; struct ctx_s * ctx = current_ctx->next;
// on vérifie si le prochain contexte n'est pas bloqué par un sémaphore
// si c'est le cas on en choisis un autre
// si on retombe sur le contexte courant, on est revenue au début de la boucle et on relance le contexte courant
while(ctx != current_ctx){ while(ctx != current_ctx){
if(ctx->state == CTX_RUN || ctx->state == CTX_INIT) if(ctx->state == CTX_RUN || ctx->state == CTX_INIT)
break; break;
...@@ -127,6 +129,9 @@ void init_mutex(semaphore * sem){ ...@@ -127,6 +129,9 @@ void init_mutex(semaphore * sem){
void sem_up(semaphore * sem){ void sem_up(semaphore * sem){
disable_it(); disable_it();
// si un context veut prendre le sem alorss qu'il n'est pas disponible
// on le bloque et on relance l'ordo
if(sem->value <= 0){ if(sem->value <= 0){
current_ctx->state = CTX_BLOCK; current_ctx->state = CTX_BLOCK;
current_ctx->sem_block = sem; current_ctx->sem_block = sem;
...@@ -140,8 +145,12 @@ void sem_down(semaphore * sem){ ...@@ -140,8 +145,12 @@ void sem_down(semaphore * sem){
struct ctx_s * ctx = current_ctx; struct ctx_s * ctx = current_ctx;
disable_it(); disable_it();
// si un context attends le sem
// on cherche parmuis les contexte lesquel sont bloqué par le sémaphore
// on fois trouver, on le remet en RUN et on relance l'ordo
if(sem->value <= 0){ if(sem->value <= 0){
// TODO
do { do {
if(ctx->state == CTX_BLOCK && ctx->sem_block == sem){ if(ctx->state == CTX_BLOCK && ctx->sem_block == sem){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment