Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ANSWERS.md 1.4KB

hw8 - Simulation 1 - Antworten

  1. Helgrind markiert die richtigen Stellen im Code:

    ==1930== Possible data race during write of size 4 at 0x60207C by thread #1
    ==1930== Locks held: none
    ==1930==    at 0x400C9A: main (main-race.c:15)
    ==1930==
    ==1930== This conflicts with a previous write of size 4 by thread #2
    ==1930== Locks held: none
    ==1930==    at 0x400C5A: worker (main-race.c:8)
    

    Weiterhin erhält man die Information über den Lock (hier none), die Art des Problems (Possible data race) und die Größe der Daten, die geschrieben werden.

  2. Codekorrektur

    1. Wenn ich eine der Zeilen lösche (bzw. auskommentiere), meldet helgrind keinen Fehler mehr (auch nicht für die zweite betreffende Zeile).

    2. Wenn man nur bei einer Variable den Lock setzt, erkennt helgrind den Fehler:

      ==18432== Possible data race during write of size 4 at 0x602084 by thread #1
      ==18432== Locks held: none
      ==18432==    at 0x400CB2: main (main-race.c:18)
      ==18432==
      ==18432== This conflicts with a previous write of size 4 by thread #2
      ==18432== Locks held: 1, at address 0x6020A0
      ==18432==    at 0x400C68: worker (main-race.c:10)
      
    3. Wenn man bei beiden Variablen einen Lock setzt, findet helgrind wieder keine Fehler.

3.

4.

  1. Blah

    1.

    2.

    3.

    4.

6.

  1. Blah

    1.

    2.

  2. Blah

    1.

    2.

9.