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

ajout de commentaire

parent 0ce9bbb7
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ char key;
void get_keyboard_input_it(int_regs_t *r);
// initialise les variables interne au bon fonctionnemebnt du clavier
void init_keyboard(){
init_mutex(&keyboard_sem);
......
......@@ -13,6 +13,7 @@ int cpt=0;
void f_ping(void *args);
void f_pong(void *args);
void f_pang(void *args);
void f_keyboard(void *args);
void f_counter(void *args);
void keyboard_it_queue(int_regs_t *r);
......@@ -47,9 +48,12 @@ void main(unsigned int * mboot_info)
puts("\n\n");
puts("\t-> Setting up the keyboard... ");
init_keyboard();
puts("OK\n");
/*** décommenté cette partie si on utilise les IT clavier ***/
// puts("\t-> Setting up the keyboard... ");
// init_keyboard();
// puts("OK\n");
__asm volatile("sti");
......@@ -58,8 +62,10 @@ void main(unsigned int * mboot_info)
/*** test sched ***/
// create_ctx(16384, f_ping, NULL);
// create_ctx(16384, f_pong, NULL);
create_ctx(16384, f_ping, NULL);
create_ctx(16384, f_pong, NULL);
create_ctx(16384, f_pang, NULL);
start_shed();
/*** test shed + sémaphore***/
......@@ -77,10 +83,10 @@ void main(unsigned int * mboot_info)
/*** test getc ***/
init_sem(&screen_sem, 1);
create_ctx(16384, f_getc, NULL);
create_ctx(16384, f_getc_b, NULL);
start_shed();
// init_sem(&screen_sem, 1);
// create_ctx(16384, f_getc, NULL);
// create_ctx(16384, f_getc_b, NULL);
// start_shed();
while(1){
//print_asciiCode();
......@@ -199,3 +205,10 @@ void f_pong(void *args){
putc('1');
}
}
void f_pang(void *args){
while(1){
putc('+');
}
}
......@@ -9,8 +9,6 @@ struct ctx_s * current_ctx = NULL;
struct ctx_s * first_ctx;
// 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){
struct ctx_s * ctx;
......@@ -27,6 +25,7 @@ void create_ctx(int stack_size, func_t f, void *args){
}
current_ctx->next = ctx;
current_ctx = ctx;
}
......@@ -98,6 +97,9 @@ void switch_to_ctx(struct ctx_s *ctx){
void my_yield(){
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){
if(ctx->state == CTX_RUN || ctx->state == CTX_INIT)
break;
......@@ -127,6 +129,9 @@ void init_mutex(semaphore * sem){
void sem_up(semaphore * sem){
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){
current_ctx->state = CTX_BLOCK;
current_ctx->sem_block = sem;
......@@ -140,8 +145,12 @@ void sem_down(semaphore * sem){
struct ctx_s * ctx = current_ctx;
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){
// TODO
do {
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 to comment