Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Ordonnancement
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
ASE-2021
Ordonnancement
Commits
65519c0e
Commit
65519c0e
authored
4 years ago
by
Thierno souleymane Bah
Browse files
Options
Downloads
Patches
Plain Diff
feat(change from 32 bits to 64 bits done, start_sched function in progress)
parent
8451ca07
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+9
-8
9 additions, 8 deletions
Makefile
display_stack.c
+5
-3
5 additions, 3 deletions
display_stack.c
try.c
+52
-15
52 additions, 15 deletions
try.c
try.h
+13
-2
13 additions, 2 deletions
try.h
with
79 additions
and
28 deletions
Makefile
+
9
−
8
View file @
65519c0e
OPTION
=
-m32
INC
=
-I
/vagrant/ASE/ordonnancement/x86-64/include
LIB
=
-L
/vagrant/ASE/ordonnancement/x86-64/lib
-lhardware
all
:
display_stack try_mul pingpong pingpongpang
display_stack
:
display_stack.o
gcc
$(
OPTION
)
-o
$@
$^
gcc
-o
$@
$^
$(
LIB
)
try_mul
:
try.o try_mul.o
gcc
$(
OPTION
)
-o
$@
$^
gcc
-o
$@
$^
$(
LIB
)
pingpong
:
try.o pingpong.o
gcc
$(
OPTION
)
-o
$@
$^
gcc
-o
$@
$^
$(
LIB
)
pingpongpang
:
try.o pingpongpang.o
gcc
$(
OPTION
)
-o
$@
$^
gcc
-o
$@
$^
$(
LIB
)
%.o
:
%.c
gcc
$(
OPTION
)
-c
$<
gcc
$(
INC
)
-c
$<
clean
:
rm
-f
*
.o
*
.s display_stack try_mul pingpong pingpongpang
\ No newline at end of file
This diff is collapsed.
Click to expand it.
display_stack.c
+
5
−
3
View file @
65519c0e
...
...
@@ -10,11 +10,13 @@ int main()
{
int
a
,
b
;
int
la
,
lb
,
lc
;
asm
(
"movl %%esp, %0"
asm
(
"mov %%rsp, %0"
"
\n\t
"
"mov
l
%%
e
bp, %1"
"mov %%
r
bp, %1"
:
"=r"
(
a
),
"=r"
(
b
));
printf
(
"esp=%p; ebp=%p
\n
"
,
&
a
,
&
b
);
printf
(
"rsp=%p; rbp=%p
\n
"
,
&
a
,
&
b
);
printf
(
"la=%p; lb=%p; lc=%p
\n
"
,
&
la
,
&
lb
,
&
lc
);
return
display
(
la
,
lb
,
lc
);
...
...
This diff is collapsed.
Click to expand it.
try.c
+
52
−
15
View file @
65519c0e
...
...
@@ -2,16 +2,17 @@
#include
<stdio.h>
#include
<assert.h>
#include
"try.h"
#include
"hardware.h"
ctx_t
*
current_ctx
=
NULL
;
ctx_t
*
last_ctx
=
NULL
;
int
try
(
ctx_t
*
pctx
,
func_t
*
f
,
int
arg
)
{
asm
(
"mov
l
%%
e
sp, %0"
asm
(
"mov %%
r
sp, %0"
"
\n\t
"
"mov
l
%%
e
bp, %1"
:
"=r"
(
pctx
->
e
sp
),
"=r"
(
pctx
->
e
bp
));
"mov %%
r
bp, %1"
:
"=r"
(
pctx
->
r
sp
),
"=r"
(
pctx
->
r
bp
));
return
f
(
arg
);
}
...
...
@@ -23,11 +24,11 @@ int throw(ctx_t * pctx, int r)
static
int
r_tmp
;
r_tmp
=
r
;
asm
(
"mov
l
%0 ,%%
e
sp"
asm
(
"mov %0 ,%%
r
sp"
"
\n\t
"
"mov
l
%1 ,%%
e
bp "
"mov %1 ,%%
r
bp "
:
:
"r"
(
pctx
->
e
sp
),
"r"
(
pctx
->
e
bp
));
:
"r"
(
pctx
->
r
sp
),
"r"
(
pctx
->
r
bp
));
return
r_tmp
;
}
...
...
@@ -35,8 +36,8 @@ int throw(ctx_t * pctx, int r)
int
init_ctx
(
ctx_t
*
pctx
,
int
stack_size
,
funct_t
f
,
void
*
args
)
{
pctx
->
stack
=
malloc
(
stack_size
);
pctx
->
e
sp
=
pctx
->
stack
+
stack_size
-
sizeof
(
void
*
);
pctx
->
e
bp
=
pctx
->
stack
+
stack_size
-
sizeof
(
void
*
);
pctx
->
r
sp
=
pctx
->
stack
+
stack_size
-
sizeof
(
void
*
);
pctx
->
r
bp
=
pctx
->
stack
+
stack_size
-
sizeof
(
void
*
);
pctx
->
f
=
f
;
pctx
->
args
=
args
;
pctx
->
status
=
CTX_INIT
;
...
...
@@ -63,18 +64,18 @@ void switch_to_ctx(ctx_t *pctx)
if
(
current_ctx
!=
NULL
)
{
// Sauvegarder où on en est avec le ctx courant
asm
(
"mov
l
%%
e
sp, %0"
asm
(
"mov %%
r
sp, %0"
"
\n\t
"
"mov
l
%%
e
bp, %1"
:
"=r"
(
current_ctx
->
e
sp
),
"=r"
(
current_ctx
->
e
bp
));
"mov %%
r
bp, %1"
:
"=r"
(
current_ctx
->
r
sp
),
"=r"
(
current_ctx
->
r
bp
));
}
current_ctx
=
pctx
;
asm
(
"mov
l
%0, %%
e
sp"
asm
(
"mov %0, %%
r
sp"
"
\n\t
"
"mov
l
%1, %%
e
bp"
"mov %1, %%
r
bp"
:
:
"r"
(
current_ctx
->
e
sp
),
"r"
(
current_ctx
->
e
bp
));
:
"r"
(
current_ctx
->
r
sp
),
"r"
(
current_ctx
->
r
bp
));
if
(
current_ctx
->
status
==
CTX_INIT
)
start_ctx
();
...
...
@@ -109,7 +110,6 @@ ctx_t *create_ctx(int stack_size, funct_t f, void *args)
void
yield
()
{
//printf("%p, %p\n", current_ctx, last_ctx);
if
(
last_ctx
==
NULL
)
{
printf
(
"
\n
End
\n
"
);
...
...
@@ -121,3 +121,40 @@ void yield()
else
switch_to_ctx
(
current_ctx
->
next_ctx
);
}
empty_it
(
void
)
{
return
;
}
void
timer_it
()
{
_out
(
TIMER_ALARM
,
0xFFFFFFFE
);
yield
();
}
void
start_sched
()
{
unsigned
int
i
;
/* init hardware */
if
(
init_hardware
(
HARDWARE_INI
)
==
0
)
{
fprintf
(
stderr
,
"Error in hardware initialization
\n
"
);
exit
(
EXIT_FAILURE
);
}
/* dummy interrupt handlers */
for
(
i
=
0
;
i
<
16
;
i
++
)
IRQVECTOR
[
i
]
=
empty_it
;
/* program timer */
IRQVECTOR
[
TIMER_IRQ
]
=
timer_it
;
_out
(
TIMER_PARAM
,
128
+
64
+
32
+
8
);
/* reset + alarm on + 8 tick / alarm / 11101000 */
_out
(
TIMER_ALARM
,
0xFFFFFFFE
);
/* alarm at next tick (at 0xFFFFFFFF) */
/* allows all IT */
_mask
(
1
);
yield
();
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
try.h
+
13
−
2
View file @
65519c0e
#if !defined(TRY)
#define TRY
#define TIMER_PARAM 0xF4
#define TIMER_ALARM 0xF8
#define TIMER_IRQ 2
#define HARDWARE_INI "hardware.ini"
typedef
int
(
func_t
)(
int
);
typedef
void
(
funct_t
)(
void
*
);
...
...
@@ -13,8 +18,8 @@ typedef enum
typedef
struct
ctx_s
{
void
*
e
sp
;
void
*
e
bp
;
void
*
r
sp
;
void
*
r
bp
;
char
*
stack
;
funct_t
*
f
;
void
*
args
;
...
...
@@ -36,4 +41,10 @@ ctx_t *create_ctx(int, funct_t, void *);
void
yield
();
void
start_sched
();
void
irq_disable
();
void
irq_enable
();
#endif // TRY
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