void *redacteur(void *args) {
    donnees_thread_t *d = args;
    int i, valeur;

    srandom((int) pthread_self());

    for (i=0; i < d->iterations; i++) {
        dodo(2);

        begin_write(d->lecteur_redacteur);

        printf("Thread %x : début rédaction......\n", (int) pthread_self());
        valeur = random();
        d->donnee = valeur;
        dodo(1);
        printf("Thread %x : ", (int) pthread_self());
        if (valeur != d->donnee)
            printf("REDACTION INCOHERENTE !!!\n");
        else
            printf("rédaction cohérente......\n");

        end_write(d->lecteur_redacteur);
    }
    pthread_exit(0);
}
Exemple #2
0
/**
 * non-declaration statement
 */
do_statement () {
        if (amatch ("if", 2)) {
                doif ();
                lastst = STIF;
        } else if (amatch ("while", 5)) {
                dowhile ();
                lastst = STWHILE;
        } else if (amatch ("switch", 6)) {
                doswitch ();
                lastst = STSWITCH;
        } else if (amatch ("do", 2)) {
                dodo ();
                need_semicolon ();
                lastst = STDO;
        } else if (amatch ("for", 3)) {
                dofor ();
                lastst = STFOR;
        } else if (amatch ("return", 6)) {
                doreturn ();
                need_semicolon ();
                lastst = STRETURN;
        } else if (amatch ("break", 5)) {
                dobreak ();
                need_semicolon ();
                lastst = STBREAK;
        } else if (amatch ("continue", 8)) {
                docont ();
                need_semicolon ();
                lastst = STCONT;
        } else if (match (";"))
                ;
        else if (amatch ("case", 4)) {
                docase ();
                lastst = statement (NO);
        } else if (amatch ("default", 7)) {
                dodefault ();
                lastst = statement (NO);
        } else if (match ("__asm__")) {
                doasm ();
                lastst = STASM;
        } else if (match("#")) {
                kill();
        } else if (match ("{"))
                do_compound (NO);
        else {
                expression (YES);
/*              if (match (":")) {
                        dolabel ();
                        lastst = statement (NO);
                } else {
*/                      need_semicolon ();
                        lastst = STEXP;
/*              }
*/      }
}
void *lecteur(void *args) {
    donnees_thread_t *d = args;
    int i, valeur;

    srandom((int) pthread_self());

    for (i=0; i < d->iterations; i++) {
        dodo(2);

        begin_read(d->lecteur_redacteur);

        printf("Thread %x : début lecture\n", (int) pthread_self());
        valeur = d->donnee;
        dodo(1);
        printf("Thread %x : ", (int) pthread_self());
        if (valeur != d->donnee)
            printf("LECTURE INCOHERENTE !!!\n");
        else
            printf("lecture cohérente\n");

        end_read(d->lecteur_redacteur);
    }
    pthread_exit(0);
}
Exemple #4
0
int stmt() { int c;
       if(istoken('{'))     {while(istoken('}')==0) stmt();}
  else if(istoken(T_IF))    doif();
  else if(istoken(T_DO))    dodo();
  else if(istoken(T_WHILE)) dowhile();
  else if(istoken(T_GOTO))  {prs("\n jmp @@");name1();prs(symbol);expect(';');}
  else if(token==T_ASM)     {prs("\n"); c=next();
    while(c != '\n') { prc(c);	c=next(); }; token=getlex(); }
  else if(istoken(T_ASMBLOCK)) {prs("\n"); expect('{'); c=next();
    while(c!= '}') { prc(c); c=next(); };   token=getlex(); }
  else if(istoken(T_EMIT))  doemit();
  else if(istoken(';'))     { }
  else if(istoken(T_RETURN)){if (token!=';') expr();
    prs("\n jmp @@retn"); nreturn++; expect(';'); }
  else if(thechar==':')     {prs("\n@@"); /*Label*/
     prs(symbol); prc(':'); expect(T_NAME); expect(':'); }
  else                      {expr(); expect(';'); } }