本文整理汇总了C++中do_sleep函数的典型用法代码示例。如果您正苦于以下问题:C++ do_sleep函数的具体用法?C++ do_sleep怎么用?C++ do_sleep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了do_sleep函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: do_sleep
void HEADBAND::all_on() {
int led;
for (led = 0; led < _nr_leds; led++) {
_leds[led].on();
}
do_sleep(64);
for (led = 0; led < _nr_leds; led++) {
_leds[led].off();
}
}
开发者ID:craighagan,项目名称:HalloweenCostumes,代码行数:10,代码来源:HEADBAND.cpp
示例2: philosopher_using_condvar
//---------- philosophers using monitor (condition variable) ----------------------
int philosopher_using_condvar(void * arg) { /* arg is the No. of philosopher 0~N-1*/
int i, iter=0;
i=(int)arg;
cprintf("I am No.%d philosopher_condvar\n",i);
while(iter++<TIMES)
{ /* iterate*/
cprintf("Iter %d, No.%d philosopher_condvar is thinking\n",iter,i); /* thinking*/
do_sleep(SLEEP_TIME);
phi_take_forks_condvar(i);
/* need two forks, maybe blocked */
cprintf("Iter %d, No.%d philosopher_condvar is eating\n",iter,i); /* eating*/
do_sleep(SLEEP_TIME);
phi_put_forks_condvar(i);
/* return two forks back*/
}
cprintf("No.%d philosopher_condvar quit\n",i);
return 0;
}
开发者ID:Silver-Shen,项目名称:OS_LAB,代码行数:20,代码来源:check_sync.c
示例3: main
int main(int argc,char *argv[])
{
char out;
int i;
#ifdef LOCK_LOCKFILE
if(argc!=3) {
fprintf(stderr,"usage:%s character lockfile\n",argv[0]);
exit(1);
}
lockfile=argv[2];
if(!(fname=malloc(strlen(lockfile)+16))) {
perror("malloc()");
exit(1);
}
sprintf(fname,"%s%d",lockfile,getpid());
signal(SIGINT,handler); /* Zajistit zrusení zámku pri násilném ukoncení */
signal(SIGTERM,handler);
signal(SIGQUIT,handler);
signal(SIGHUP,handler);
#else
if(argc!=2) {
fprintf(stderr,"usage: %s character\n",argv[0]);
exit(1);
}
#endif
out=argv[1][0];
for(;;) {
LOCK
for(i=0;i<LINE_LEN;i++) {
if(write(1,&out,1)==-1) {
perror("write()");
exit(1);
}
do_sleep(SLEEP_CHAR);
}
if(write(1,"\n",1)==-1) {
perror("write()");
exit(1);
}
UNLOCK
do_sleep(SLEEP_LINE);
}
}
开发者ID:ozw1z5rd,项目名称:FUN,代码行数:43,代码来源:lock.c
示例4: philosopher_using_semaphore
int philosopher_using_semaphore(void * arg) /* i:哲学家号码,从0到N-1 */
{
int i, iter=0;
i=(int)arg;
cprintf("I am No.%d philosopher_sema\n",i);
while(iter++<TIMES)
{ /* 无限循环 */
cprintf("Iter %d, No.%d philosopher_sema is thinking\n",iter,i); /* 哲学家正在思考 */
do_sleep(SLEEP_TIME);
phi_take_forks_sema(i);
/* 需要两只叉子,或者阻塞 */
cprintf("Iter %d, No.%d philosopher_sema is eating\n",iter,i); /* 进餐 */
do_sleep(SLEEP_TIME);
phi_put_forks_sema(i);
/* 把两把叉子同时放回桌子 */
}
cprintf("No.%d philosopher_sema quit\n",i);
return 0;
}
开发者ID:Silver-Shen,项目名称:OS_LAB,代码行数:19,代码来源:check_sync.c
示例5: idle_task
/* idle task */
static void idle_task(void)
{
while(1)
{
#ifdef BUILD_ARM_BB
do_work();
#else
do_sleep();
#endif
}
}
开发者ID:adalu838,项目名称:datateknikreal,代码行数:12,代码来源:si_kernel.c
示例6: update_target
void update_target (CHAR_DATA *tch, int affect_type)
{
if ( affect_type == MAGIC_AFFECT_SLEEP ) {
do_sleep (tch, "", 0);
if ( tch->fighting ) {
if ( tch->fighting == tch )
stop_fighting (tch->fighting);
stop_fighting (tch);
}
}
}
开发者ID:stefanludlow,项目名称:Argila,代码行数:11,代码来源:magic.c
示例7: stop
ATMO_BOOL CFnordlichtConnection::reset(unsigned char addr)
{
if(m_hComport == INVALID_HANDLE_VALUE)
return ATMO_FALSE;
stop(255);
if ( sync() && start_bootloader(addr) )
{
#if defined(_ATMO_VLC_PLUGIN_)
do_sleep(200000); // wait 200ms
#else
do_sleep(200); // wait 200ms
#endif
if ( sync() && boot_enter_application(addr) )
return ATMO_TRUE;
}
return ATMO_FALSE;
}
开发者ID:BloodExecutioner,项目名称:vlc,代码行数:20,代码来源:FnordlichtConnection.cpp
示例8: body
int body()
{
char c;
printf("proc %d starts from body()\n", running->pid);
while(1)
{
printf("-----------------------------------------\n");
//prints the list of procs that are initializedd and free
printf("freelist = ");
printQueue(freeList);// optional: show the freeList
//print ready queue which are procs that are ready
printf("readyQueue = ");
printQueue(readyQueue); // show the readyQueue
//printf("sleepList = ");
//printQueue(sleepList);
printf("-----------------------------------------\n");
printf("proc %d running: parent=%d\n",running->pid,running->ppid);
printf("enter a char [s|f|q z|a|w] : ");
c = getc();
printf("%c\n", c);
switch(c)
{
case 'f': //fork a child off of the current process
do_kfork();
break;
case 's': //switch to next process in ready queue
do_tswitch();
break;
case 'q': //zombie the current process
do_exit();
break;
case 'z': //running PROC go to sleep on an event value
do_sleep();
break;
case 'a': //wakeup all PROCs sleeping on event
do_wakeup();
break;
case 'w': //to wait for a ZOMBIE child
do_wait();
break;
}
}
}
开发者ID:lldarrow,项目名称:CptS-460-Operating-Systems,代码行数:51,代码来源:t.c
示例9: test_1
//
// void test_1()
//
// This test insures that Timers are constructed properly.
//
static void test_1()
{
spica::Timer object_1;
// Sleep for a while. If the timer is running (shouldn't be) let's
// give it a chance to accumulate some time.
//
std::cout << "Test #1: Sleeping for 5 seconds..." << std::endl;
do_sleep(5);
// It should have just sat there.
std::cout << " object_1's time is: " << object_1.time()
<< "ms (should be zero)" << std::endl;
}
开发者ID:pchapin,项目名称:spica,代码行数:19,代码来源:Timer_tests.cpp
示例10: other
/** @brief Pauses the writes, so that you can manipulate the base object (the formatters/destinations, for instance)
After this function has been called, you can be @b sure that the other (dedicated) thread is not writing any messagges.
In other words, the other thread is not manipulating the base object (formatters/destinations, for instance), but you can do it.
FIXME allow a timeout as well
*/
void pause() {
{ scoped_lock lk( non_const_context_base::context().cs);
non_const_context_base::context().is_paused = true;
non_const_context_base::context().pause_acknowledged = false;
}
while ( true) {
do_sleep(10);
scoped_lock lk( non_const_context_base::context().cs);
if ( non_const_context_base::context().pause_acknowledged )
// the other thread has acknowledged
break;
}
}
开发者ID:ST3ALth,项目名称:libed2k,代码行数:21,代码来源:on_dedicated_thread.hpp
示例11: random
void HEADBAND::start() {
int led;
int action = random(17);
switch (action) {
case 0:
case 1:
// strobe up
strobe_up();
break;
case 2:
case 3:
// strobe down
strobe_down();
break;
case 5:
strobe_up();
strobe_down();
break;
case 6:
case 7:
case 8:
case 9:
led = random(_nr_leds);
_leds[led].choose();
break;
case 10:
glow_up();
break;
case 11:
glow_down();
break;
case 12:
glow_all();
break;
case 13:
blink_all(random(3));
break;
case 14:
shira_morse();
break;
case 15:
alternate(random(5) + 5);
break;
case 16:
all_on();
break;
}
do_sleep(random(15) * 1000);
}
开发者ID:craighagan,项目名称:HalloweenCostumes,代码行数:50,代码来源:HEADBAND.cpp
示例12: handle_signal
void handle_signal(int signal) {
const char *signal_name;
sigset_t pending;
// Find out which signal we're handling
switch (signal) {
case SIGHUP:
signal_name = "SIGHUP";
break;
case SIGUSR1:
signal_name = "SIGUSR1";
break;
case SIGINT:
printf("Caught SIGINT, exiting now\n");
exit(0);
default:
fprintf(stderr, "Caught wrong signal: %d\n", signal);
return;
}
/*
* Please note that printf et al. are NOT safe to use in signal handlers.
* Look for async safe functions.
*/
printf("Caught %s, sleeping for ~3 seconds\n"
"Try sending another SIGHUP / SIGINT / SIGALRM "
"(or more) meanwhile\n", signal_name);
/*
* Indeed, all signals are blocked during this handler
* But, at least on OSX, if you send 2 other SIGHUP,
* only one will be delivered: signals are not queued
* However, if you send HUP, INT, HUP,
* you'll see that both INT and HUP are queued
* Even more, on my system, HUP has priority over INT
*/
do_sleep(5);
printf("Done sleeping for %s\n", signal_name);
// So what did you send me while I was asleep?
sigpending(&pending);
if (sigismember(&pending, SIGHUP)) {
printf("A SIGHUP is waiting\n");
}
if (sigismember(&pending, SIGUSR1)) {
printf("A SIGUSR1 is waiting\n");
}
printf("Done handling %s\n\n", signal_name);
}
开发者ID:DCordella,项目名称:Code,代码行数:49,代码来源:main.cpp
示例13: body
int body()
{
char c;
color = running->pid + 7;
printf("\nproc %d resumes to body()\n", running->pid);
while(1){
color = running->pid + 7;
printQueue(freeList, "freeList");
printQueue(readyQueue, "readyQueue");
printf("proc %d running : \nenter a key (s|q|f | z|a|w): ", running->pid);
c = getc();
printf("%c\n", c);
switch(c)
{
case 's':
tswitch();
break;
case 'q':
do_exit();
break;
case 'f':
do_kfork();
break;
case 'z':
//printf("sleep\n");
do_sleep();
//go to sleep on an even
break;
case 'a':
//printf("wake up\n");
do_wakeup();
//wakeup all procs sleeping on event
break;
case 'w':
//printf("wait\n");
do_wait();
//wait for a ZOMBIE child
break;
}
//tswitch();
}
}
开发者ID:tymicruz,项目名称:CuatroSeisZero,代码行数:48,代码来源:t.c
示例14: one_measurement
void one_measurement(int seconds, char *workload)
{
create_all_usb_devices();
start_power_measurement();
devices_start_measurement();
start_process_measurement();
start_cpu_measurement();
if (workload && workload[0]) {
if (system(workload))
fprintf(stderr, _("Unknown issue running workload!\n"));
} else {
do_sleep(seconds);
}
end_cpu_measurement();
end_process_measurement();
collect_open_devices();
devices_end_measurement();
end_power_measurement();
process_cpu_data();
process_process_data();
/* output stats */
process_update_display();
report_summary();
w_display_cpu_cstates();
w_display_cpu_pstates();
if (reporttype != REPORT_OFF) {
report_display_cpu_cstates();
report_display_cpu_pstates();
}
report_process_update_display();
tuning_update_display();
end_process_data();
global_joules_consumed();
compute_bundle();
show_report_devices();
report_show_open_devices();
report_devices();
ahci_create_device_stats_table();
store_results(measurement_time);
end_cpu_data();
}
开发者ID:shaobinzhang,项目名称:powertop,代码行数:48,代码来源:main.cpp
示例15: master
void master()
{
pid_t server_pid, client_pid;
// handle error properly, otherwise
/* start the server */
spawn(server, &server_pid);
do_sleep(10);
/* start the client */
spawn(client, &client_pid);
/* wait all */
waitpid(client_pid);
waitpid(server_pid);
return;
}
开发者ID:FranciscoMeloJr,项目名称:workload-kit,代码行数:17,代码来源:cpm3.c
示例16: one_measurement
void one_measurement(int seconds, char *workload)
{
create_all_usb_devices();
start_power_measurement();
devices_start_measurement();
start_process_measurement();
start_cpu_measurement();
if (workload && workload[0]) {
system(workload);
} else {
do_sleep(seconds);
}
end_cpu_measurement();
end_process_measurement();
collect_open_devices();
devices_end_measurement();
end_power_measurement();
process_cpu_data();
process_process_data();
/* output stats */
process_update_display();
report_summary();
w_display_cpu_cstates();
w_display_cpu_pstates();
report_display_cpu_cstates();
report_display_cpu_pstates();
report_process_update_display();
tuning_update_display();
end_process_data();
global_joules_consumed();
compute_bundle();
show_report_devices();
report_show_open_devices();
report_devices();
store_results(measurement_time);
end_cpu_data();
}
开发者ID:lbt,项目名称:powertop,代码行数:46,代码来源:main.cpp
示例17: run_test
void run_test(int64_t delay_ns)
{
for (int i = 0; i <= 25; i++) {
int64_t start, finish;
start = get_ns();
do_get(key, 0);
finish = get_ns();
int64_t elapsed = finish - start;
if (i > 0) {
printf("%f\n", elapsed / 1e9);
fflush(stdout);
}
do_sleep(delay_ns);
}
}
开发者ID:richwolski,项目名称:bluesky,代码行数:17,代码来源:readdelay.c
示例18: do_client_run
void do_client_run(ctx_t *ctx)
{
int full = ctx->size;
int half = ctx->size >> 1;
int cnt = 0;
/* 1 */
do_recv(ctx, full, cnt++);
/* 3 */
do_recv(ctx, full, cnt);
/* 4 */
do_recv(ctx, half, cnt++);
do_recv(ctx, half, cnt++);
do_sleep(50);
}
开发者ID:FranciscoMeloJr,项目名称:workload-kit,代码行数:18,代码来源:cpm3.c
示例19: do_server_run
void do_server_run(ctx_t *ctx)
{
int full = ctx->size;
int half = ctx->size >> 1;
int cnt = 0;
/* 1 */
do_send(ctx, full, cnt++);
/* 3 */
do_send(ctx, half, cnt);
do_send(ctx, half, cnt++);
/* 4 */
do_send(ctx, full, cnt++);
do_sleep(50);
}
开发者ID:FranciscoMeloJr,项目名称:workload-kit,代码行数:18,代码来源:cpm3.c
示例20: main
int main(void)
{
// Attiny13A fuse setting: -U lfuse:w:0x7A:m -U hfuse:w:0xFB:m
//
// set system-clock prescaler to 1/8
// 4.8MHz RC-oscillator --> 600kHz system-clock
CLKPR = _BV(CLKPCE);
CLKPR = _BV(CLKPS1) | _BV(CLKPS0);
// configure TIMER0
TCCR0A = _BV(WGM01); // set CTC mode
TCCR0B = ( _BV(CS01) ); // set prescaler to 8
// enable COMPA ISR
TIMSK0 = _BV(OCIE0A);
// set top value for TCNT0
OCR0A = 10; // just some start value
// pull-up on for BUTTON_PIN
PORT_OUT_REG |= _BV(BUTTON_PIN);
// set port directions
PORT_DIR_REG = PORT_DIR_MASK;
// disable analog comparator to save power
ACSR = _BV(ACD);
// Pin change interrupt enabled
// The actual pin will be activated later
GIMSK |= _BV(PCIE);
// globally enable interrupts
// necessary to wake up from sleep via pin-change interrupt
sei();
fade(0,255,1);
while (1) {
// the flag 'sleep_requested' is set in the ISR: TIM0_COMPA_vect
if(sleep_requested == 1) {
do_sleep();
}
flicker();
}
}
开发者ID:akafugu,项目名称:ledcandle,代码行数:43,代码来源:main.c
注:本文中的do_sleep函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论