void barrier(int tId) { if(tId < 0 || tId >= size) { printf("O_O\n"); return; } if(tId == 0) { sendRight(tId); printf("sR %d\n", tId); receiveRight(tId); printf("rR %d\n", tId); } if(tId == size-1) { receiveLeft(tId); printf("rL %d\n", tId); sendLeft(tId); printf("sL %d\n", tId); } if(0 < tId && tId < size) { receiveLeft(tId); printf("rL %d\n", tId); sendRight(tId); printf("sR %d\n", tId); receiveRight(tId); printf("rR %d\n", tId); sendLeft(tId); printf("sL %d\n", tId); } }
Seconds CPUTime::forCurrentThread() { mach_msg_type_number_t infoCount = THREAD_BASIC_INFO_COUNT; thread_basic_info_data_t info; auto threadPort = MachSendRight::adopt(mach_thread_self()); auto ret = thread_info(threadPort.sendRight(), THREAD_BASIC_INFO, reinterpret_cast<thread_info_t>(&info), &infoCount); RELEASE_ASSERT(ret == KERN_SUCCESS); return Seconds(info.user_time.seconds + info.system_time.seconds) + Seconds::fromMicroseconds(info.user_time.microseconds + info.system_time.microseconds); }