time clock代写

10/13/2018 H7

H7

Due Friday by 6:30pm Points 2

The file timer.h has a macro that can be used to get elapsed time in seconds of a block of code. To use it, you need a copy of timer.h in the directory containing your C source. You also need to include it in your C source with #include “timer.h”. (Note that you need double-quotes around timer.h, not angle- brackets.) You also need to declare a couple of doubles — call them start and finish:

double start, finish;
Just before the block of code you want time, you should add the line

GET_TIME(start);

This will store the current time in seconds in the variable start. Note that since GET_TIME is a macro, you should just use the variable start as the argument, and *not* a pointer to start. Just after the block of code you want to time, you should add the line

GET_TIME(finish);

Now the difference finish-start stores elapsed time for the block of code.

For this assignment you should time the execution of the code that implements spinlocks using the C atomic_exchange function: atex_lock.c . You should also time the execution of the code that implements spinlocks using ARMv8 ldxr-stxr:

slock1.c and slock1_funcs.s

You should start the timer just before the calls to pthread_create, and you should stop the timer just after the calls to pthread_join. How does the performance using C’s atomic_exchange compare to the performance of the ARMv8 ldx-stxr with 4 threads and 1,000,000 iterations per thread? Submit your modified code, and include your comments on performance in the documentation of atex_lock.c

https://usfca.instructure.com/courses/1579371/assignments/6782177 1/1