本文整理汇总了C++中TIME_IN_USEC函数的典型用法代码示例。如果您正苦于以下问题:C++ TIME_IN_USEC函数的具体用法?C++ TIME_IN_USEC怎么用?C++ TIME_IN_USEC使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TIME_IN_USEC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: server_procedure
void server_procedure(struct command_line_args *object)
{
struct packet *p;
My402ListElem *elem = NULL;
struct timespec tim;
double time;
long time_diff_in_nsec;
int i = 0;
while( i < object->no_of_packets && !EndServerThread)
{
pthread_mutex_lock(&token_bucket);
while(My402ListEmpty(&Q2PacketList)&&!EndServerThread)
pthread_cond_wait(&is_q2_empty,&token_bucket);
if(EndServerThread == 1)
{
pthread_mutex_unlock(&token_bucket);
break;
}
elem = My402ListFirst(&Q2PacketList);
if(elem == NULL)
{
pthread_mutex_unlock(&token_bucket);
break;
}
p = (struct packet *)elem->obj;
My402ListUnlink(&Q2PacketList, elem);
pthread_mutex_unlock(&token_bucket);
gettimeofday(&(p->Q2leaves), NULL);
time = (TIME_IN_USEC(p->Q2leaves) - TIME_IN_USEC(GlobalStartTime))/1000;
p->time_in_Q2 = (TIME_IN_USEC(p->Q2leaves) - TIME_IN_USEC(p->Q2timestamp))/1000;
LOG(stdout, "%012.3fms: p%d begin service at S, time in Q2 = %.3fms\n",time,p->packet_id,p->time_in_Q2);
time_diff_in_nsec = (long)((((p->precise_packet_service_time)/1000) - (p->service_time/1000))*1000000000L);
tim.tv_sec = (p->service_time)/1000;
tim.tv_nsec = time_diff_in_nsec;
nanosleep(&tim, NULL);
gettimeofday(&(p->Leaves_server), NULL);
time = (TIME_IN_USEC(p->Leaves_server) - TIME_IN_USEC(GlobalStartTime))/1000;
p->time_in_system = (TIME_IN_USEC(p->Leaves_server) - TIME_IN_USEC(p->Arrival_timestamp))/1000;
p->precise_packet_service_time = (TIME_IN_USEC(p->Leaves_server) - TIME_IN_USEC(p->Q2leaves))/1000;
LOG(stdout, "%012.3fms: p%d departs from S, service time = %.3fms, time in system = %.3fms\n",time,p->packet_id,p->precise_packet_service_time,p->time_in_system);
completed_packets ++;
calculate_stats(p);
if((packet_count == object->no_of_packets) &&(completed_packets == (packet_count-discarded_packets)) && My402ListEmpty(&Q2PacketList))
{
EndServerThread = 1;
pthread_cond_signal(&is_q2_empty);
}
i++;
}
pthread_exit(NULL);
}
示例2: atarisys2_interrupt
int atarisys2_interrupt (void)
{
int i;
/* set the 32V timer */
timer_set (TIME_IN_USEC (Machine->drv->vblank_duration), 0, atarisys2_32v_interrupt);
timer_set (TIME_IN_USEC (Machine->drv->vblank_duration), 0, atarisys2_video_update);
/* update the pedals once per frame */
for (i = 0; i < pedal_count; i++)
{
if (readinputport (3 + i) & 0x80)
{
pedal_value[i] += 64;
if (pedal_value[i] > 0xff) pedal_value[i] = 0xff;
}
else
{
pedal_value[i] -= 64;
if (pedal_value[i] < 0) pedal_value[i] = 0;
}
}
/* VBLANK is 3 */
if (!irq_hold3 && (READ_WORD (&atarisys2_interrupt_enable[0]) & 8))
{
irq_hold3 = 1;
return 3;
}
else
return ignore_interrupt ();
}
示例3: WRITE16_HANDLER
static WRITE16_HANDLER( hypr_subcpu_control_w )
{
int pc = activecpu_get_pc();
if (data & 0x01)
{
if (!subcpu_resetline)
{
if (pc != 0x95f2)
{
cpunum_set_input_line(1, INPUT_LINE_RESET, ASSERT_LINE);
subcpu_resetline = 1;
} else {
cpunum_set_input_line(1, INPUT_LINE_HALT, ASSERT_LINE);
subcpu_resetline = -1;
}
}
} else {
if (subcpu_resetline == 1 && (data != 0x0c))
{
cpunum_set_input_line(1, INPUT_LINE_RESET, CLEAR_LINE);
subcpu_resetline = 0;
if (pc == 0xbb0 || pc == 0x9d30 || pc == 0xb19c)
cpu_spinuntil_time(TIME_IN_USEC(15000)); /* sync semaphore */
}
else if (subcpu_resetline == -1)
{
cpunum_set_input_line(1, INPUT_LINE_HALT, CLEAR_LINE);
subcpu_resetline = 0;
}
}
}
示例4: via_irq
static void via_irq(int state)
{
/* Kaos sits in a tight loop polling the VIA irq flags register, but that register is
cleared by the irq handler. Therefore, I wait a bit before triggering the irq to
leave time for the program to see the flag change. */
timer_set(TIME_IN_USEC(50), state, via_irq_delayed);
}
示例5: digdug_customio_w
void digdug_customio_w(int offset,int data)
{
if (errorlog && data != 0x10 && data != 0x71) fprintf(errorlog,"%04x: custom IO command %02x\n",cpu_get_pc(),data);
customio_command = data;
switch (data)
{
case 0x10:
if (nmi_timer) timer_remove (nmi_timer);
nmi_timer = 0;
return;
case 0xa1: /* go into switch mode */
mode = 1;
break;
case 0xc1:
case 0xe1: /* go into credit mode */
mode = 0;
break;
case 0xb1: /* status? */
credits = 0; /* this is a good time to reset the credits counter */
break;
}
nmi_timer = timer_pulse (TIME_IN_USEC (50), 0, digdug_nmi_generate);
}
示例6: coco_fdc_callback
static void coco_fdc_callback(int event)
{
switch(event) {
case WD179X_IRQ_CLR:
intrq_state = CLEAR_LINE;
cpunum_set_input_line(0, INPUT_LINE_NMI, CLEAR_LINE);
break;
case WD179X_IRQ_SET:
intrq_state = ASSERT_LINE;
CLEAR_COCO_HALTENABLE;
coco_set_halt_line(CLEAR_LINE);
if( COCO_NMIENABLE )
timer_set( TIME_IN_USEC(0), 0, raise_nmi);
else
cpunum_set_input_line(0, INPUT_LINE_NMI, CLEAR_LINE);
break;
case WD179X_DRQ_CLR:
drq_state = CLEAR_LINE;
if( COCO_HALTENABLE )
timer_set( TIME_IN_CYCLES(7,0), 0, raise_halt);
else
coco_set_halt_line(CLEAR_LINE);
break;
case WD179X_DRQ_SET:
drq_state = ASSERT_LINE;
coco_set_halt_line(CLEAR_LINE);
break;
}
}
示例7: gottlieb_speech_w
void gottlieb_speech_w(int offset, int data)
{
data ^= 255;
/* generate a NMI after a while to make the CPU continue to send data */
timer_set(TIME_IN_USEC(50),0,gottlieb_nmi_generate);
}
示例8: centronics_write_handshake
void centronics_write_handshake(int nr, int data, int mask)
{
CENTRONICS *This=cent+nr;
int neu=(data&mask)|(This->control&(~mask));
if (neu & CENTRONICS_NO_RESET)
{
if ( !(This->control&CENTRONICS_STROBE) && (neu&CENTRONICS_STROBE) )
{
printer_output(image_from_devtype_and_index(IO_PRINTER, nr), This->data);
/* setup timer for data acknowledge */
/* set mask for data that has changed */
This->new_control_mask = CENTRONICS_ACKNOWLEDGE;
/* set data that has changed */
This->new_control_data = CENTRONICS_ACKNOWLEDGE;
/* setup a new timer */
timer_adjust(This->timer, TIME_IN_USEC(1), nr, 0);
}
}
This->control=neu;
}
示例9: cpu_vblankcallback
static void cpu_vblankcallback(int param)
{
int cpunum;
if (vblank_countdown == 1)
vblank = 1;
/* loop over CPUs */
for (cpunum = 0; cpunum < cpu_gettotalcpu(); cpunum++)
{
/* if the interrupt multiplier is valid */
if (cpu[cpunum].vblankint_multiplier != -1)
{
/* decrement; if we hit zero, generate the interrupt and reset the countdown */
if (!--cpu[cpunum].vblankint_countdown)
{
/* a param of -1 means don't call any callbacks */
if (param != -1)
{
/* if the CPU has a VBLANK handler, call it */
if (Machine->drv->cpu[cpunum].vblank_interrupt && cpu_getstatus(cpunum))
{
cpuintrf_push_context(cpunum);
(*Machine->drv->cpu[cpunum].vblank_interrupt)();
cpuintrf_pop_context();
}
/* update the counters */
cpu[cpunum].iloops--;
}
/* reset the countdown and timer */
cpu[cpunum].vblankint_countdown = cpu[cpunum].vblankint_multiplier;
timer_adjust(cpu[cpunum].vblankint_timer, TIME_NEVER, 0, 0);
}
}
/* else reset the VBLANK timer if this is going to be a real VBLANK */
else if (vblank_countdown == 1)
timer_adjust(cpu[cpunum].vblankint_timer, TIME_NEVER, 0, 0);
}
/* is it a real VBLANK? */
if (!--vblank_countdown)
{
/* do we update the screen now? */
if (!(Machine->drv->video_attributes & VIDEO_UPDATE_AFTER_VBLANK))
time_to_quit = updatescreen();
/* Set the timer to update the screen */
timer_set(TIME_IN_USEC(Machine->drv->vblank_duration), 0, cpu_updatecallback);
/* reset the globals */
cpu_vblankreset();
/* reset the counter */
vblank_countdown = vblank_multiplier;
}
}
示例10: set_coco_dskreg
static void set_coco_dskreg(int data)
{
UINT8 drive = 0;
UINT8 head = 0;
int motor_mask = 0;
LOG(("set_coco_dskreg(): %c%c%c%c%c%c%c%c ($%02x)\n",
data & 0x80 ? 'H' : 'h',
data & 0x40 ? '3' : '.',
data & 0x20 ? 'D' : 'S',
data & 0x10 ? 'P' : 'p',
data & 0x08 ? 'M' : 'm',
data & 0x04 ? '2' : '.',
data & 0x02 ? '1' : '.',
data & 0x01 ? '0' : '.',
data ));
/* An email from John Kowalski informed me that if the DS3 is
* high, and one of the other drive bits is selected (DS0-DS2), then the
* second side of DS0, DS1, or DS2 is selected. If multiple bits are
* selected in other situations, then both drives are selected, and any
* read signals get yucky.
*/
motor_mask = 0x08;
if (data & 0x04)
drive = 2;
else if (data & 0x02)
drive = 1;
else if (data & 0x01)
drive = 0;
else if (data & 0x40)
drive = 3;
else
motor_mask = 0;
head = ((data & 0x40) && (drive != 3)) ? 1 : 0;
dskreg = data;
if( COCO_HALTENABLE && (drq_state == CLEAR_LINE) )
timer_set( TIME_IN_CYCLES(7,0), 0, raise_halt);
else
coco_set_halt_line(CLEAR_LINE);
if( COCO_NMIENABLE && (intrq_state == ASSERT_LINE) )
{
CLEAR_COCO_HALTENABLE;
coco_set_halt_line(CLEAR_LINE);
timer_set( TIME_IN_USEC(0), 0, raise_nmi);
}
else
cpunum_set_input_line(0, INPUT_LINE_NMI, CLEAR_LINE);
wd179x_set_drive(drive);
wd179x_set_side(head);
wd179x_set_density( (dskreg & 0x20) ? DEN_MFM_LO : DEN_FM_LO );
}
示例11: josvolly_8741_do
static void josvolly_8741_do(int num)
{
if( (i8741[num].sts & 0x02) )
{
/* transmit data */
timer_set (TIME_IN_USEC(1),num,josvolly_8741_tx);
}
}
示例12: foodf_interrupt
int foodf_interrupt (void)
{
/* INT 2 once per frame in addition to... */
if (cpu_getiloops () == 0)
timer_set (TIME_IN_USEC (100), 0, foodf_delayed_interrupt);
/* INT 1 on the 32V signal */
return 1;
}
示例13: delayed_sound_w
static void delayed_sound_w(int param)
{
main_to_sound_data = param;
main_to_sound_ready = 1;
cpu_triggerint(1);
/* use a timer to make long transfers faster */
timer_set(TIME_IN_USEC(50), 0, 0);
}
示例14: WRITE_HANDLER
static WRITE_HANDLER( xain_sharedram_w )
{
/* locations 003d and 003e are used as a semaphores between CPU A and B, */
/* so let's resync every time they are changed to avoid deadlocks */
if ((offset == 0x003d || offset == 0x003e)
&& xain_sharedram[offset] != data)
cpu_boost_interleave(0, TIME_IN_USEC(20));
xain_sharedram[offset] = data;
}
示例15: apple1_dsp_ready_start
static void apple1_dsp_ready_start(int dummy)
{
/* When the display asserts \RDA to signal it is ready, it
triggers a 74123 one-shot to send a 3.5-usec low pulse to PIA
input CB1. The end of this pulse will tell the PIA that the
display is ready for another write. */
pia_set_input_cb1(0, 0);
timer_set(TIME_IN_USEC(3.5), 0, apple1_dsp_ready_end);
}