int main(int argc, char* argv[]) { double t0, t1; int i; if (argc != 2) { printf("Usage: nbody [number of bodies]\n"); exit(-1); } sscanf(argv[1], "%d", &number_of_bodies); #pragma omp target update to(number_of_bodies) Initialize(); #pragma omp target map(to:Position_X[0:number_of_bodies], \ Position_Y[0:number_of_bodies], Position_Z[0:number_of_bodies], \ Mass[0:number_of_bodies]) \ map(tofrom:Acceleration[0:3*number_of_bodies]) { // Reinitialize the output arrays after the warmup run to get the right debug sum in the end Perform_NBody(); for (i = 0; i < 3 * number_of_bodies; i++) Acceleration[i] = 0; t0 = omp_get_wtime(); Perform_NBody(); t1 = omp_get_wtime(); Checking(); } Checking(); printf("Run time = %f seconds.\n", t1-t0); }
int main ( ) { Initialization( ) ; // Initialize LCD Printfunction( "Press key" ) ; _delay_ms ( 10 ) ; Commandfunction( 0x01 ) ; _delay_ms ( 2 ) ; for ( ;; ) { Keypad_Out = 0xF0 ; // row =0, col =1 _delay_ms ( 20 ) ; unsigned char buffer = Keypad_In ; if ( buffer != 0xF0 ) { // i.e any column key is pressed // now repeated same thing again to ensure that key was pressed _delay_ms( 20 ) ; buffer = Keypad_In ; if ( buffer != 0xF0 ) Checking( ) ; // some key is pressed } } }
bool ShareInfo::CleanupNetDrive(DWORD cur, int *_vacant) { CheckInfo ci; if (!Checking(cur, 0, &ci, true)) return false; int &vacant = *_vacant; int netdrv_max = 0; vacant = -1; for (int i=0; i < head->netDrvMax; i++) { if (head->netDrive[i].hash == 0) { if (vacant == -1) vacant = i; continue; } if ((cur - head->netDrive[i].last) > CHECK_CYCLE_TICK) { if (((1ULL << (i + FINFO_NETDRV_BASE)) & ci.use_drives) == 0) { head->netDrive[i].hash = 0; head->netDrive[i].last = 0; if (vacant == -1) vacant = i; continue; } else { head->netDrive[i].last = cur; } } netdrv_max = i+1; } head->netDrvMax = netdrv_max; if (vacant == -1 && head->netDrvMax < FINFO_MAXNETDRV) { vacant = head->netDrvMax++; } return vacant >= 0; }
bool ShareInfo::GetCount(CheckInfo *ci, uint64 use_drives) { if (!Lock()) return false; bool ret = Checking(GetTickCount(), use_drives, ci); UnLock(); return ret; }
int FooIn( struct SchoolList *pPupil ) { int i; int ind = 1; if( pPupil == ZERO ) { i = -1; puts( "Warning!!! Application doesn't use normally memory. Please restart application for normally work!" ); return i; } else if( pPupil != ZERO ) { LINE puts("\t- Welcome! - To the \"School List\" system"); LINE for( i = ZERO; i != KILK4; ++i ) { /* Autor Surname */ while( ind ) { puts( "Please, enter pupil's surname:" ); scanf( "%s", pPupil -> surname ); ind = Checking(); LINE } ++ind; /* Autor Name*/ while( ind ) { puts( "Please, enter pupil's name:" ); scanf( "%s", pPupil -> name ); ind = Checking(); LINE } ++ind; ++pPupil; } }
bool ShareInfo::TakeExclusive(uint64 use_drives, int max_running, bool is_force, ShareInfo::CheckInfo *_ci) { if (!head || IsTaken()) return false; if (!Lock()) false; bool ret = false; DWORD cur = ::GetTickCount(); CheckInfo ci_tmp; CheckInfo &ci = _ci ? *_ci : ci_tmp; Checking(cur, use_drives, &ci); if (ci.self_idx == -1 && hSelfMutex || ci.self_idx >= 0 && !hSelfMutex) { // 不整合検出 ReleaseExclusiveCore(); } if (!hSelfMutex) { char mutex[100]; MakeMutexName(mutex, selfCount = ++head->mutexCount); if (!(hSelfMutex = ::CreateMutex(0, TRUE, mutex))) goto END; } if (ci.self_idx == -1) { if (head->total >= FINFO_MAXPROC) goto END; ci.self_idx = head->total++; } Head::Data &data = head->data[ci.self_idx]; data.last = cur; data.mutexCount = selfCount; data.mode = selfMode = (is_force || (ci.all_running < max_running && ci.tgt_running == 0 && (ci.wait_top_idx == -1 || ci.self_idx < ci.wait_top_idx))) ? TAKE : WAIT; data.useDrives = use_drives; ret = IsTaken(); END: UnLock(); return ret; }