| 1 | ==== Esempi con la syscall `clone`, specifica di Linux ==== |
| 2 | |
| 3 | * Thread '''senza''' memoria condivisa export:trunk/threads-isolated.c |
| 4 | [[IncludeSource(trunk/threads-isolated.c, line_numbers=0)]] |
| 5 | |
| 6 | * Thread '''con''' memoria condivisa export:trunk/threads-shared.c |
| 7 | [[IncludeSource(trunk/threads-shared.c, line_numbers=0)]] |
| 8 | |
| 9 | * Thread '''con''' memoria condivisa, mutua esclusione ottenuta con Peterson export:trunk/threads-peterson.c |
| 10 | [[IncludeSource(trunk/threads-peterson.c, line_numbers=0)]] |
| 11 | |
| 12 | * Thread '''con''' memoria condivisa, mutua esclusione con TSL export:trunk/threads-tsl.c export:trunk/enter.asm |
| 13 | [[IncludeSource(trunk/threads-tsl.c, line_numbers=0)]] |
| 14 | [[IncludeSource(trunk/enter.asm, line_numbers=0)]] |
| 15 | |
| 16 | {{{ |
| 17 | #!sh |
| 18 | nasm -felf enter.asm |
| 19 | cc threads-tsl.c enter.o -o threads-tsl |
| 20 | }}} |
| 21 | |
| 22 | |
| 23 | ==== Esempi in Java ==== |
| 24 | |
| 25 | * Creazione di thread export:trunk/Basic.java |
| 26 | [[IncludeSource(trunk/Basic.java, line_numbers=0)]] |
| 27 | |
| 28 | * Memoria condivisa export:trunk/Shared.java |
| 29 | [[IncludeSource(trunk/Shared.java, line_numbers=0)]] |
| 30 | |
| 31 | * Memoria condivisa, mutua esclusione ottenuta con `synchronized`, export:trunk/Shared2.java |
| 32 | [[IncludeSource(trunk/Shared2.java, line_numbers=0)]] |
| 33 | |
| 34 | |
| 35 | * Produttore e consumatore, export:trunk/PC.java |
| 36 | [[IncludeSource(trunk/PC.java, line_numbers=0)]] |