• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ spin函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中spin函数的典型用法代码示例。如果您正苦于以下问题:C++ spin函数的具体用法?C++ spin怎么用?C++ spin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了spin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

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();
}
开发者ID:mbansal2090,项目名称:OS_XV6_HW2,代码行数:27,代码来源:default_priority.c


示例2: main

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;
}
开发者ID:fuinha,项目名称:roscar,代码行数:27,代码来源:roscar.cpp


示例3: while

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;
		}
	}
}
开发者ID:jessewalton,项目名称:USF-Object-Oriented-Design,代码行数:25,代码来源:SlotMachine.cpp


示例4: test_cv_thread

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);
}
开发者ID:vaibhavvijay,项目名称:ECE-344,代码行数:34,代码来源:test_thread.c


示例5: redDevansh

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
}
开发者ID:joseph-zhong,项目名称:Robotics,代码行数:29,代码来源:917B-AlexLakeWashington1_3.c


示例6: main

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();
    }   
}
开发者ID:bhdminh,项目名称:uGFX,代码行数:27,代码来源:main.c


示例7: arp_layer_receive

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");
}
开发者ID:weiweishuo,项目名称:papaya,代码行数:26,代码来源:arp.c


示例8: main

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();
}
开发者ID:vener91,项目名称:cs537,代码行数:60,代码来源:usage.c


示例9: assertion_failure

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");

}
开发者ID:huangyukun2012,项目名称:DIY_kernel,代码行数:7,代码来源:err.c


示例10: ASSERT

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;
}
开发者ID:Karvjorm,项目名称:haiku,代码行数:29,代码来源:engine.cpp


示例11: TestA

/*======================================================================*
                               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");
}
开发者ID:Garfield-Chen,项目名称:hf-2011,代码行数:63,代码来源:main.c


示例12: check_service_req

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;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:29,代码来源:basic_protocol.c


示例13: ioremap

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);
}
开发者ID:weiweishuo,项目名称:papaya,代码行数:7,代码来源:ioremap.c


示例14: rem_init

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;
}
开发者ID:iitalics,项目名称:cforth,代码行数:25,代码来源:serialio.c


示例15: task_hd

/**
 * 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);
    }
}
开发者ID:wwssllabcd,项目名称:myOS,代码行数:39,代码来源:hd.c


示例16: quality

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;

   }
}
开发者ID:jlane-waikato,项目名称:IQmol,代码行数:60,代码来源:MolecularOrbitalsConfigurator.C


示例17: graph

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);
}
开发者ID:nutjunkie,项目名称:IQmol,代码行数:35,代码来源:ExcitedStatesConfigurator.C


示例18: main

int main(int argc, char* argv[])
{
    signal (SIGINT, sigintHandler);
    printf("\033[?25l");  // Hide cursor
    spin();
    return 0;
}
开发者ID:hammerhorn,项目名称:hammerhorn-jive,代码行数:7,代码来源:spinner.c


示例19: redUdit

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);
}
开发者ID:joseph-zhong,项目名称:Robotics,代码行数:33,代码来源:917B-JosephLakeWashington1_2.c


示例20: redDevansh

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);
}
开发者ID:joseph-zhong,项目名称:Robotics,代码行数:33,代码来源:917B-JosephLakeWashington1_2.c



注:本文中的spin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ spin_is_locked函数代码示例发布时间:2022-05-30
下一篇:
C++ spiffs_get_cache函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap