loader now return better understanable errors, fix when compiler when to use bss section, add join exception, fix get_string_param, add support for thread in obbAddr, add a test
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
PROGRAMS = halt.guac prints.guac
|
||||
PROGRAMS = halt.guac prints.guac producteur_consommateur.guac
|
||||
TOPDIR = ../..
|
||||
include $(TOPDIR)/Makefile.rules
|
||||
|
||||
|
48
test/syscall_tests/producteur_consommateur.c
Normal file
48
test/syscall_tests/producteur_consommateur.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include "userlib/syscall.h"
|
||||
#include "userlib/libnachos.h"
|
||||
|
||||
|
||||
const int N = 3;
|
||||
int iplein = 0;
|
||||
int ivide = 0;
|
||||
int tab[3];
|
||||
SemId svide;
|
||||
SemId splein;
|
||||
|
||||
void producteur();
|
||||
|
||||
void consommateur();
|
||||
|
||||
int main() {
|
||||
svide = SemCreate("producteur", N);
|
||||
splein = SemCreate("consommateur", 0);
|
||||
ThreadId producteurTh = threadCreate("producteur", producteur);
|
||||
ThreadId consommateurTh = threadCreate("consommateur", consommateur);
|
||||
Join(producteurTh);
|
||||
Join(consommateurTh);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void producteur() {
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
n_printf("batir une information\n");
|
||||
P(svide);
|
||||
iplein = (iplein + 1) % N;
|
||||
n_printf("communique une information : %d\n", i);
|
||||
tab[iplein] = i;
|
||||
V(splein);
|
||||
}
|
||||
}
|
||||
|
||||
void consommateur() {
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
P(splein);
|
||||
ivide = (ivide +1) % N;
|
||||
n_printf("recevoir une information\n");
|
||||
int info = tab[ivide];
|
||||
V(svide);
|
||||
n_printf("exploiter l'information : %d\n", info);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user