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:
Quentin Legot
2023-04-13 00:18:35 +02:00
parent 05f72af035
commit f144438490
6 changed files with 130 additions and 34 deletions

View File

@ -1,4 +1,4 @@
PROGRAMS = halt.guac prints.guac
PROGRAMS = halt.guac prints.guac producteur_consommateur.guac
TOPDIR = ../..
include $(TOPDIR)/Makefile.rules

View 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);
}
}