(1) I need to time the execution of some procedure that uses multiple threads to do the execution. See the code attached.
The problem is that start and finish both receive the value 0 from clock(). I made some defines large so that the execution would take a 3-4 seconds (in case the timing wasn't very precise), yet those variables always get the value 0 returned from clock(). Thus, the time elapsed is always 0.
I'm wondering if the fact that I spawn threads from the main process has anything to do with clock() returning zero? I don't see why it should, but this is my first time programming with threads.
(2) A misc question I have is regarding struct declarations in C++. See the attached code. Does using typedef in the second version mean that I can use
stuff someStuff;
instead of
struct stuff someStuff;
? Or is there other differences between the two?
(3) edit: Also, one other question. I attached the code (the delete part maybe not be the correct syntax, but you get the idea). Both creating the 2D threads array on the stack and the heap seem to work the same. I was thinking maybe it should go on the heap since each thread has their own stack, but share the heap. But I guess each thread doesn't actually use the threads[][] itself... only the process creating them uses it to keep track of them.
Thanks!
The problem is that start and finish both receive the value 0 from clock(). I made some defines large so that the execution would take a 3-4 seconds (in case the timing wasn't very precise), yet those variables always get the value 0 returned from clock(). Thus, the time elapsed is always 0.
I'm wondering if the fact that I spawn threads from the main process has anything to do with clock() returning zero? I don't see why it should, but this is my first time programming with threads.
(2) A misc question I have is regarding struct declarations in C++. See the attached code. Does using typedef in the second version mean that I can use
stuff someStuff;
instead of
struct stuff someStuff;
? Or is there other differences between the two?
(3) edit: Also, one other question. I attached the code (the delete part maybe not be the correct syntax, but you get the idea). Both creating the 2D threads array on the stack and the heap seem to work the same. I was thinking maybe it should go on the heap since each thread has their own stack, but share the heap. But I guess each thread doesn't actually use the threads[][] itself... only the process creating them uses it to keep track of them.
Thanks!