cs252/lab4-src
2018-10-25 14:45:56 -04:00
..
count Re-add files 2018-10-25 14:45:56 -04:00
count_spin Re-add files 2018-10-25 14:45:56 -04:00
count_spin.cc Re-add files 2018-10-25 14:45:56 -04:00
count.cc Re-add files 2018-10-25 14:45:56 -04:00
deadlock Re-add files 2018-10-25 14:45:56 -04:00
deadlock.cc Re-add files 2018-10-25 14:45:56 -04:00
hello-syscall Re-add files 2018-10-25 14:45:56 -04:00
hello-syscall.c Re-add files 2018-10-25 14:45:56 -04:00
Makefile Re-add files 2018-10-25 14:45:56 -04:00
README Re-add files 2018-10-25 14:45:56 -04:00
strace.out Re-add files 2018-10-25 14:45:56 -04:00
syscall Re-add files 2018-10-25 14:45:56 -04:00
syscall.c Re-add files 2018-10-25 14:45:56 -04:00
t2.out Re-add files 2018-10-25 14:45:56 -04:00
t.out Re-add files 2018-10-25 14:45:56 -04:00
thr1 Re-add files 2018-10-25 14:45:56 -04:00
thr1.cc Re-add files 2018-10-25 14:45:56 -04:00
thr2 Re-add files 2018-10-25 14:45:56 -04:00
thr2.cc Re-add files 2018-10-25 14:45:56 -04:00

Step 3
Alternating blocks of A's, B's, and C's are printed. Process switching is somewhat visible via the blocks that the letters print in.

Step 5
The main thread gets thrown into a while loop which blocks the program from progressing to the point at which it would create the threads.

                                                 | Real  | User  | Kernel |
-------------------------------------------------+-------+-------+--------+
pthread_mutex()                                  | 3.158 | 3.660 | 2.588  |
spin_lock() (count_spin with pthread_yield())    | 1.750 | 2.688 | 0.700  |
spin_lock() (count_spin without pthread_yield()) | 2.700 | 5.360 | 0.000  |

The user time without yielding the thread exceeds the the user time with thread yielding because without yielding, the thread uses 100% of the time busy waiting. The CPU control is never returned to other processes, instead it is simply burned.

When a mutex is used, the context is switched to other processes. When this occurs, kernel mode is required. Thus mutex uses more kernel/system time than user time.