I’m trying to implement the task switch Rhealstone benchmark in Linux. Here is the original code:
http://pastebin.com/aYF4Tnvt
And here is what I’ve written so far:
http://pastebin.com/tX7zK7h7
The problem is that the for loops run for a random few times and the program quits. Anyone can point me to the right direction? I’m a noob programmer and I’m really lost with this stuff.
join() the threads in main(). You are falling out of main and exiting your program which kills the other threads. Change the code to something like
Not sure exactly where you want to put that end timer. In this manner you would also be timing the two calls to join() but they should be minimal. If you put the timer before the join then you will be ending your timer way before your threads actually end – all you will be timing is how long it takes to for two create_thread calls to complete.