Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
my-kernel-michiels-saulquin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Michiels
my-kernel-michiels-saulquin
Commits
865093e8
Commit
865093e8
authored
4 years ago
by
Lunala
Browse files
Options
Downloads
Patches
Plain Diff
ajout de commentaire
parent
0ce9bbb7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/keyboard.c
+1
-0
1 addition, 0 deletions
src/keyboard.c
src/main.c
+22
-9
22 additions, 9 deletions
src/main.c
src/ordo.c
+13
-4
13 additions, 4 deletions
src/ordo.c
with
36 additions
and
13 deletions
src/keyboard.c
+
1
−
0
View file @
865093e8
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
src/main.c
+
22
−
9
View file @
865093e8
...
@@ -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
(
'+'
);
}
}
This diff is collapsed.
Click to expand it.
src/ordo.c
+
13
−
4
View file @
865093e8
...
@@ -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
){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment