int main(int argc, char *argv[]) { struct pstat st; int highpriority = 0; int pid = getpid(); int defaultpriorityrun = 0; spin(); check(getpinfo(&st) == 0, "getpinfo"); int i; printf(1, "\n **** PInfo **** \n"); for(i = 0; i < NPROC; i++) { if (st.inuse[i]) { if(st.hticks[i] != 0) highpriority++; if(st.pid[i] == pid && st.lticks[i] > 20) defaultpriorityrun = 1; printf(1, "pid: %d hticks: %d lticks: %d\n", st.pid[i], st.hticks[i], st.lticks[i]); } } check(highpriority == 0, "getpinfo shouldn't return any process with hticks not equal to 0, default priority should be low(1) "); check(defaultpriorityrun == 1, "getpinfo should return a process having run with default priority"); printf(1, "Should print 1 then 2"); exit(); }
int main(int argc, char **argv) { if (argc < 2) return usage(); const char *cmd = argv[1]; perish_if(libusb_init(NULL) < 0, "Couldn't init libusb"); libusb_device_handle *h = libusb_open_device_with_vid_pid(NULL, VENDOR_ID, PRODUCT_ID); perish_if(h == NULL, "couldn't find or open device. check permissions?"); perish_if(0 != libusb_claim_interface(h, 0), "couldn't claim interface"); printf("device opened successfully.\n"); signal(SIGINT, signal_handler); if (!strcmp(cmd, "stream")) stream(h); else if (!strcmp(cmd, "blink")) blink(h); else if (!strcmp(cmd, "spin")) spin(h); else if (!strcmp(cmd, "listen")) { ros::init(argc, argv, "roscar_driver"); roscar_listen(h); } libusb_exit(NULL); return 0; }
void SlotMachine::play(Player &player) { int menuSelect = 0; bool continueLoop = true; int bet = 0; static int run = 0; while (continueLoop) { if (run++ == 0) { buildMachine(player); // just for show to build display } if (processInput(bet)) { spin(bet, player); } else { continueLoop = false; run = 0; } } }
static void test_cv_thread(unsigned long num) { int i; struct timeval start, end, diff; for (i = 0; i < LOOPS; i++) { lock_acquire(testlock); while (testval1 != num) { gettimeofday(&start, NULL); cv_wait(testcv, testlock); gettimeofday(&end, NULL); timersub(&end, &start, &diff); /* cv_wait should wait at least 4-5 ms */ if (diff.tv_sec == 0 && diff.tv_usec < 4000) { unintr_printf("%s took %ld us. That's too fast." " You must be busy looping\n", __FUNCTION__, diff.tv_usec); goto out; } } unintr_printf("%d: thread %3d passes\n", i, num); testval1 = (testval1 + NTHREADS - 1) % NTHREADS; /* spin for 5 ms */ spin(5000); cv_broadcast(testcv, testlock); lock_release(testlock); } out: __sync_fetch_and_add(&done, 1); }
void redDevansh() // Places preload (1-2) + 2 buckies (2-4) + TURN LEFT Knocks buckies (1-6) { deploy(); intake(1); wait10Msec(10); moveStraight(1, 0, 455); //picks up wait10Msec(50); moveStraight(-1, 0, 475);//comes back intake(0); // end part 1: prepare dump waitForButton(); lift(BUMP); holdArm(); intake(-1); resetValues(1200); // end part 2: dump waitForButton(); liftDown(); wait10Msec(100); moveStraight(1, 0, 700); // end part 3: prepare hit spin(-1, 0, 200); intake(-1); lift(BUMP); holdArm(); noRamp(1, 250); resetValues(0); // end part 4: hit }
int main(void) { /* Initialize and clear the display */ gfxInit(); gdispClear(White); /* Create the 3D window */ { GWindowInit wi; gwinClearInit(&wi); wi.show = TRUE; wi.x = (gdispGetWidth()-GL3D_WINDOW_SIZE)/2; wi.y = (gdispGetHeight()-GL3D_WINDOW_SIZE)/2; wi.width = GL3D_WINDOW_SIZE; wi.height = GL3D_WINDOW_SIZE; gh = gwinGL3DCreate(0, &wi); } /* Init the 3D stuff */ setup(); init(); while(TRUE) { // rate control gfxSleepMilliseconds(FRAME_DELAY); // move and redraw spin(); } }
void arp_layer_receive( struct sk_buff *comer_skb ){ assert(comer_skb->pkgsize = 14 + 28); struct arphdr *arphdr = (void *)(comer_skb->ethhdr + 1); comer_skb->arphdr = arphdr; ////////////Entry here !! ///////////network byte order to host order, only performed on arp header BYTE_ENDIAN_FLIP2(arphdr->hardware); BYTE_ENDIAN_FLIP2(arphdr->protocol); BYTE_ENDIAN_FLIP2(arphdr->operation); BYTE_ENDIAN_FLIP4(arphdr->myip); BYTE_ENDIAN_FLIP4(arphdr->yourip); //////////done //u8 *mac = arphdr->mymac; //oprintf("arp layer receive: operation=%u, from mac(%x %x %x %x %x %x)", arphdr->operation, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); if(arphdr->operation == 1){ /* it's an inquiry */ arp_respond(comer_skb); } else if(arphdr->operation == 2){ /* it's a REPLY */ arp_act(comer_skb); } else spin("unknown operation"); //oprintf(" ARP layer exit\n"); }
int main(int argc, char *argv[]) { if (argc < 3) { printf(1, "Usage: usage ticks tickets1 [tickets2]...\n\n"); printf(1, "Spawns subprocesses, each of which will run for \n" "approximately the given number of ticks. For each ticket\n" "ammount given, a child process will spawn and request that\n" "number of tickets.\n"); exit(); } int total = 0; int i; for (i = 0; i < argc - 2; i++) { total += atoi(argv[i+2]); } int ret = settickets(total); if (ret < 0) { printf(1, "settickets failed\n"); exit(); } // pids of children int pids[NPROC]; // spawn children for (i = 0; i < argc - 2; i++) { pids[i] = fork(); if (pids[i] == 0) { int ret = settickets(atoi(argv[i + 2])); if (ret < 0) { printf(1, "settickets failed\n"); exit(); } // spin so we get scheduled while(1) { spin(); } } } // print usage info int ticks = atoi(argv[1]); int start = uptime(); while(uptime() < start + ticks) { sleep(100); printf(1, "time: %d\n", uptime() - start); printinfo(); } // kill children for (i = 0; i < argc - 2; i++) { kill(pids[i]); wait(); } exit(); }
void assertion_failure(char *exp, char *file, char * base_file, int line) { printl("%c assert(%s) failed: file: %s, base_file: %s,ln%d",MAG_CH_ASSERT,exp, file, base_file, line); spin("assertion_failure()"); __asm__ __volatile__("ud2"); }
void QueueCommands::MakeSpace(uint32 size) { ASSERT((size & 1) == 0); size *= sizeof(uint32); bigtime_t start = system_time(); while (fRingBuffer.space_left < size) { // wait until more space is free uint32 head = read32(fRingBuffer.register_base + RING_BUFFER_HEAD) & INTEL_RING_BUFFER_HEAD_MASK; if (head <= fRingBuffer.position) head += fRingBuffer.size; fRingBuffer.space_left = head - fRingBuffer.position; if (fRingBuffer.space_left < size) { if (system_time() > start + 1000000LL) { TRACE(("intel_extreme: engine stalled, head %lx\n", head)); break; } spin(10); } } fRingBuffer.space_left -= size; }
/*======================================================================* TestA *======================================================================*/ void TestA() { int fd; int i, n; char filename[MAX_FILENAME_LEN+1] = "blah"; const char bufw[] = "abcde"; const int rd_bytes = 3; char bufr[rd_bytes]; assert(rd_bytes <= strlen(bufw)); /* create */ fd = open(filename, O_CREAT | O_RDWR); assert(fd != -1); printf("File created: %s (fd %d)\n", filename, fd); /* write */ n = write(fd, bufw, strlen(bufw)); assert(n == strlen(bufw)); /* close */ close(fd); /* open */ fd = open(filename, O_RDWR); assert(fd != -1); printf("File opened. fd: %d\n", fd); /* read */ n = read(fd, bufr, rd_bytes); assert(n == rd_bytes); bufr[n] = 0; printf("%d bytes read: %s\n", n, bufr); /* close */ close(fd); char * filenames[] = {"/foo", "/bar", "/baz"}; /* create files */ for (i = 0; i < sizeof(filenames) / sizeof(filenames[0]); i++) { fd = open(filenames[i], O_CREAT | O_RDWR); assert(fd != -1); printf("File created: %s (fd %d)\n", filenames[i], fd); close(fd); } char * rfilenames[] = {"/bar", "/foo", "/baz", "/dev_tty0"}; /* remove files */ for (i = 0; i < sizeof(rfilenames) / sizeof(rfilenames[0]); i++) { if (unlink(rfilenames[i]) == 0) printf("File removed: %s\n", rfilenames[i]); else printf("Failed to remove file: %s\n", rfilenames[i]); } spin("TestA"); }
bool check_service_req(ide_device_info *device) { ide_bus_info *bus = device->bus; int status; // fast bailout if there is no request pending if (device->num_running_reqs == 0) return false; if (bus->active_device != device) { // don't apply any precautions in terms of IRQ // -> the bus is in accessing state, so IRQs are ignored anyway if (bus->controller->write_command_block_regs(bus->channel_cookie, &device->tf, ide_mask_device_head) != B_OK) // on error, pretend that this device asks for service // -> the disappeared controller will be recognized soon ;) return true; bus->active_device = device; // give one clock (400 ns) to take notice spin(1); } status = bus->controller->get_altstatus(bus->channel_cookie); return (status & ide_status_service) != 0; }
void * ioremap(unsigned phys_addr, int size, unsigned flags){ if(phys_addr >> 30) { oprintf(" %x ", phys_addr); spin("too big IO physical address"); } return (void *)(phys_addr + PAGE_OFFSET); }
void rem_init() { PMC_PCER = US0_PID; US0_CR = RXDIS | TXDIS | RSTRX | RSTTX | RSTSTA; USART0(PTCR) = RXTDIS | TXTDIS; nextbyte = &ubuf[0]; nextbuf = &ubuf[0]; // Both buffers are already attached now USART0(RPR) = (u_long) &ubuf[0]; USART0(RCR) = (u_long) UBUFLEN; USART0(RNPR) = (u_long) &ubuf[UBUFLEN]; USART0(RNCR) = (u_long) UBUFLEN; USART0(PTCR) = RXTEN; US0_BRGR = BAUD_115200; US0_RTOR = 18; // bit times of delay before timeout US0_MR = PAR_NONE | CHMODE_NORMAL | USCLKS_MCK | CHRL_8 | NBSTOP_1 | STTTO; spin(1000); US0_CR = RXEN | TXEN; // junk = (u_char)US0_RHR; // Junk leftover from break // junk = (u_char)US0_RHR; }
/** * Main loop of HD driver. * *****************************************************************************/ PUBLIC void task_hd() { MESSAGE msg; init_hd(); while (1) { send_recv(RECEIVE, ANY, &msg); int src = msg.source; switch (msg.type) { case DEV_OPEN: hd_open(msg.DEVICE); break; case DEV_CLOSE: hd_close(msg.DEVICE); break; case DEV_READ: case DEV_WRITE: hd_rdwt(&msg); break; case DEV_IOCTL: hd_ioctl(&msg); break; default: dump_msg("HD driver::unknown msg", &msg); spin("FS::main_loop (invalid msg.type)"); break; } send_recv(SEND, src, &msg); } }
void AHCIPort::ResetDevice() { if (fRegs->cmd & PORT_CMD_ST) TRACE("AHCIPort::ResetDevice PORT_CMD_ST set, behaviour undefined\n"); // perform a hard reset fRegs->sctl = (fRegs->sctl & ~0xf) | 1; FlushPostedWrites(); spin(1100); fRegs->sctl &= ~0xf; FlushPostedWrites(); if (wait_until_set(&fRegs->ssts, 0x1, 100000) < B_OK) { TRACE("AHCIPort::ResetDevice port %d no device detected\n", fIndex); } // clear error bits fRegs->serr = fRegs->serr; FlushPostedWrites(); if (fRegs->ssts & 1) { if (wait_until_set(&fRegs->ssts, 0x3, 500000) < B_OK) { TRACE("AHCIPort::ResetDevice port %d device present but no phy " "communication\n", fIndex); } } // clear error bits fRegs->serr = fRegs->serr; FlushPostedWrites(); }
void MolecularOrbitals::on_addToQueueButton_clicked(bool) { int quality(m_configurator.quality->value()); double isovalue(m_configurator.isovalue->value()); Data::Spin spin(m_configurator.alphaRadio->isChecked() ? Data::Alpha : Data::Beta); QColor positive(Preferences::PositiveSurfaceColor()); QColor negative(Preferences::NegativeSurfaceColor()); bool simplifyMesh(m_configurator.simplifyMeshCheckBox->isChecked()); int index(m_configurator.surfaceType->currentIndex()); QVariant qvar(m_configurator.surfaceType->itemData(index)); bool isSigned(true); int op(m_configurator.opacity->value()); double opacity = op == 100 ? 0.999 : double(op)/100.0; Data::SurfaceInfo info(Data::SurfaceType::Custom, quality, isovalue, positive, negative, isSigned, simplifyMesh, opacity); switch (qvar.toUInt()) { case Orbital: { if (spin == Data::Alpha) { info.type().setKind(Data::SurfaceType::AlphaOrbital); }else { info.type().setKind(Data::SurfaceType::BetaOrbital); } int orb1(m_configurator.orbitalRangeMin->currentIndex()+1); int orb2(m_configurator.orbitalRangeMax->currentIndex()+1); for (int i = std::min(orb1,orb2); i <= std::max(orb1, orb2); ++i) { info.type().setIndex(i); queueSurface(info); } } break; case Density: { info.setIsSigned(false); info.type().setKind(Data::SurfaceType::TotalDensity); queueSurface(info); } break; case SpinDiffDensity: { info.type().setKind(Data::SurfaceType::SpinDensity); queueSurface(info); } break; case SpinOnlyDensity: { info.setIsSigned(false); if (spin == Data::Alpha) { info.type().setKind(Data::SurfaceType::AlphaDensity); }else { info.type().setKind(Data::SurfaceType::BetaDensity); } queueSurface(info); } break; } }
void ExcitedStates::moSelectionChanged(bool tf) { QCPGraph* graph(qobject_cast<QCPGraph*>(sender())); if (!tf || !graph) { m_configurator.orbitalLabel->setText(""); return; } bool ok(true);; unsigned orb(graph->name().toUInt(&ok)); if (!ok) return; Data::OrbitalSymmetries const& orbitals(m_excitedStates.stateData().orbitalSymmetries()); unsigned nOrbs(orbitals.nOrbitals()); Data::Spin spin(Data::Alpha); if (orb >= nOrbs) { orb -= nOrbs; spin = Data::Beta; } double energy(orbitals.energy(spin, orb)); QString symmetry(orbitals.symmetry(Data::Alpha, orb)); QString label(Data::SpinLabel(spin)); label += " " + QString::number(orb+1); label += " orbital energy: "; label += QString::number(energy, 'f', 3); label += " Eh"; if (!symmetry.isEmpty()) label += " Irrep " + symmetry; m_configurator.orbitalLabel->setText(label); }
int main(int argc, char* argv[]) { signal (SIGINT, sigintHandler); printf("\033[?25l"); // Hide cursor spin(); return 0; }
void redUdit() { deploy(); intake(true); wait10Msec(10); moveStraight(1, 0, 475); wait10Msec(50); moveStraight(-1, 0, 475); //stopIntake(); lift(BUMP); holdArm(); waitForButton(); intake(false); wait10Msec(100); waitForButton(); resetValues(0); liftDown(); // end Devansh waitForButton(); intake(true); moveStraight(1, 0, (HALF_TILE)); wait10Msec(50); pickUpBall(1); spin(-1, 0, 200); crossBump(); lift(BARRIER); holdArm(); wait10Msec(30); moveStraight(1, 0, 550); intake(false); // end udit resetValues(1000); }
void redDevansh() // Places preload (1-2) + 2 buckies (2-4) + TURN LEFT Knocks buckies (1-6) + Places two Balls (2) { deploy(); intake(true); wait10Msec(10); moveStraight(1, 0, 475); wait10Msec(50); moveStraight(-1, 0, 475); //stopIntake(); lift(BUMP); holdArm(); waitForButton(); intake(false); wait10Msec(100); waitForButton(); resetValues(0); liftDown(); // end Devansh waitForButton(); intake(true); moveStraight(1, 0, (HALF_TILE)); wait10Msec(50); pickUpBall(1); spin(-1, 0, 200); crossBump(); lift(BARRIER); holdArm(); wait10Msec(30); moveStraight(1, 0, 550); intake(false); // end udit resetValues(1000); }
void TransformManipulator::perform(const Ray * r) { if(isDetached()) return; const Vector3F worldP = worldSpace().getTranslation(); Matrix44F ps; parentSpace(ps); Plane pl(ps.transformAsNormal(hitPlaneNormal()), worldP); Vector3F hit, d; float t; if(pl.rayIntersect(*r, hit, t, 1)) { d = hit - worldP; if(d.length() > 10.f) return; if(m_mode == ToolContext::RotateTransform) { d = d.normal() * 8.f; hit = worldP + d; } d = hit - m_currentPoint; if(m_mode == ToolContext::MoveTransform) move(d); else spin(d); m_currentPoint = hit; } }
void BCS_wf::restoreUpdate(Sample_point * sample, int e, Wavefunction_storage * wfstore) { BCS_wf_storage * store; recast(wfstore, store); jast.restoreUpdate(sample,e,store->jast_store); detVal=store->detVal; inverse=store->inverse; // // unpaired electrons go into extra one-body orbitals, this // functionality will be resurrected later // //int nmo=moVal.GetDim(1); //int nd=moVal.GetDim(2); //for(int m=0; m< nmo; m++) { // for(int d=0; d< nd; d++) { // moVal(e,m,d)=store->moVal(m,d); // } //} if(spin(e)==0) { int nj=derivatives.GetDim(1); assert(nj==nelectrons(0)); int nd=derivatives.GetDim(2); for(int j=0; j< nj; j++) { for(int d=0; d< nd; d++) { derivatives(e,j,d)=store->derivatives(j,d); } } int ep=e+nelectrons(0); for(int j=0; j< nj; j++) { for(int d=0; d< nd; d++) { derivatives(ep,j,d)=store->derivatives(j+nelectrons(0),d); } } } else { int ni=derivatives.GetDim(0); assert(ni==2*nelectrons(0)); int nd=derivatives.GetDim(2); int rede=e-nelectrons(0); for(int i=0; i< ni; i++) { for(int d=0; d< nd; d++) { derivatives(i,rede,d)=store->derivatives(i,d); } } } electronIsStaleLap=0; electronIsStaleVal=0; updateEverythingLap=0; updateEverythingVal=0; //calcLap(sample); }
/** * The second routine for test. * * @test just for test *****************************************************************************/ void TestB() { while(1){} assert(0); /* never arrive here */ spin("TestB()"); }
void Certificate_Store_In_SQL::remove_key(const Private_Key& key) { auto fpr = key.fingerprint("SHA-256"); auto stmt = m_database->new_statement("DELETE FROM " + m_prefix + "keys WHERE fingerprint == ?1"); stmt->bind(1,fpr); stmt->spin(); }
void Session_Manager_SQL::remove_entry(const std::vector<byte>& session_id) { auto stmt = m_db->new_statement("delete from tls_sessions where session_id = ?1"); stmt->bind(1, hex_encode(session_id)); stmt->spin(); }
/*======================================================================* TestB *======================================================================*/ void TestC() { spin("TestC"); /* assert(0); */ while(1){ printf("C"); milli_delay(200); } }
/// Go to origin, reset orientation Nav& home(){ quat().identity(); view(0, 0, 0); turn(0, 0, 0); spin(0, 0, 0); vec().set(0); updateDirectionVectors(); return *this; }
void FDIReceiver::DisablePLL() { CALLED(); uint32 targetRegister = fRegisterBase + PCH_FDI_RX_CONTROL; write32(targetRegister, read32(targetRegister) & ~FDI_RX_PLL_ENABLED); read32(targetRegister); spin(100); }
void task_fs(){ #ifdef DEBUG_FS printl("in task_fs\n"); #endif init_fs(); MESSAGE message; memset(&message,0,sizeof(message)); while(TRUE){ send_receive(RECEIVE,ANY,&message); int source_pid=message.source_pid; int fd; switch(message.type){ case INFO_FS_CREATE: message.res_bool=do_create(&message); break; case INFO_FS_UNLINK: message.res_bool=do_unlink(&message); break; case INFO_FS_LS: message.res_int=do_ls(&message); break; case INFO_FS_OPEN: fd=do_open(&message); message.fd=fd; break; case INFO_FS_READ: do_read(&message); break; case INFO_FS_WRITE: do_write(&message); break; case INFO_FS_SEEK: do_seek(&message); break; case INFO_FS_CLOSE: message.res_int=do_close(&message); break; default: printl("\n\n\nunknown message type:%d\n",message.type); assert(FALSE,"unknown message type!"); } if(message.type!=INFO_SUSPEND_PROCESS){ send_receive(SEND,source_pid,&message); }else{ printl("inof_suspend_process\n"); } } #ifndef _FS_H_ #define _FS_H_ #endif /* _FS_H_ */ while(1) ; spin("never here"); }