Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DWORD WINAPI Set_prior( LPVOID lpParam )
- {
- Parameter* p = (Parameter*)lpParam;
- int blocked = -1;
- while(1)
- {
- //long int time_ms = (( clock()-p->start_time ) * 1000 / CLOCKS_PER_SEC );
- DWORD time_ms = timeGetTime() - p->start;
- if( time_ms % 300 == 0 && time_ms != 0 && blocked !=time_ms )// && time_ms != 0 && time_ms != blocked ) // zmienna blocked uniemozliwia wejscie do tego ifa wiecej niz raz w tej samej milisekundzie
- {
- blocked = time_ms;
- for( int i = 0; i < p->nSize; i++ )
- SuspendThread( p->thread_handles[i] );
- //EnterCriticalSection( &cs );
- printf( "\n%d\n", timeGetTime() - p->start );
- int min = p->stored_value[0];
- int max = p->stored_value[0];
- for( int i = 1; i < p->nSize; i++ )
- {
- if( min > p->stored_value[i] )
- min = p->stored_value[i];
- if( max < p->stored_value[i] )
- max = p->stored_value[i];
- }
- for( int i = 0; i < p->nSize; i++ )
- {
- //if( hektor->kupione[i] == min )
- if( p->stored_value[i] == min )
- {
- SetThreadPriority(p->thread_handles[i], 2 );
- printf( "Ochroniarz: Klient %c Zapraszam\n", p->names[i] );
- }
- //else if( hektor->kupione[i] == max )
- else if( p->stored_value[i] == max )
- {
- SetThreadPriority( p->thread_handles[i], -2 );
- printf( "Ochroniarz: Klient %c Na Koniec\n", p->names[i] );
- }
- else SetThreadPriority( p->thread_handles[i], 0 );
- }
- for( int i = 0; i < p->nSize; i++ )
- ResumeThread( p->thread_handles[i] );
- //LeaveCriticalSection( &cs );
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement