void team_barrier() { const bool not_root = m_team_rank + 1 < m_team_size ; for ( int i = 0 ; i < m_fan_team_size ; ++i ) { spinwait( m_fan_team[i]->m_state_team , OpenMPexec::Active ); } if ( not_root ) { m_state_team = Rendezvous ; spinwait( m_state_team , OpenMPexec::Rendezvous ); } for ( int i = 0 ; i < m_fan_team_size ; ++i ) { m_fan_team[i]->m_state_team = OpenMPexec::Active ; } }
DWORD WINAPI consumerthread(LPVOID thread) { DWORD threadID=GetCurrentThreadId(); EnterCriticalSection(&cs); printf("Spawning Consumer"); dequeue(); LeaveCriticalSection(&cs); SetEvent(Ready); spinwait(Ptime*100000); return 0; }
DWORD WINAPI producerthread(LPVOID thread) { DWORD threadID=GetCurrentThreadId(); int i; for(i=1; i<=X;i++) { EnterCriticalSection(&cs); enqueue(i); LeaveCriticalSection(&cs); SetEvent(Ready); } spinwait(Ptime*100000); return 0; }
findcpuspeed() { unsigned char low; unsigned int remainder; /* Put counter in count down mode */ outb(IO_TIMER1+3, 0x34); outb(IO_TIMER1, 0xff); outb(IO_TIMER1, 0xff); delaycount = FIRST_GUESS; spinwait(1); /* Read the value left in the counter */ low = inb(IO_TIMER1); /* least siginifcant */ remainder = inb(IO_TIMER1); /* most significant */ remainder = (remainder<<8) + low ; /* Formula for delaycount is : * (loopcount * timer clock speed)/ (counter ticks * 1000) */ delaycount = (FIRST_GUESS * (XTALSPEED/1000)) / (0xffff-remainder); }