I wrote this for an OS class assignment that I\'ve already completed and handed in. I posted this question yesterday, but due to \"Academic Honesty\" regulations I took it off u
The OP does not mention/show any code that indicates the thread(s) sleep, wait, give up execution, etc and all the threads are at the same 'nice' level.
so an individual thread may well get the CPU and not release it until it has completed all 2mil executions.
This would result in a minimal amount of time performing context switches, on linux.
However, on the MAC OS, a execution is only given a 'time slice' to execute, before another 'ready to execute' thread/process is allowed to execute.
This means many many more context switches.
Context switches are performed in 'sys' time.
The result is the MAC OS will take much longer to execute.
To even the playing field, you could force context switches, by inserting a nanosleep() or a call to release execution via
#include
then calling
int sched_yield(void);