void
sys_timer_set( SysTimer  timer, SysTime  when, SysCallback   _callback, void*  opaque )
{
    QEMUTimerCB*  callback = (QEMUTimerCB*)_callback;

    if (callback == NULL) {  /* unsetting the timer */
        if (timer->timer) {
            timer_del( timer->timer );
            timer_free( timer->timer );
            timer->timer = NULL;
        }
        timer->callback = callback;
        timer->opaque   = NULL;
        return;
    }

    if ( timer->timer ) {
         if ( timer->callback == callback && timer->opaque == opaque )
            goto ReuseTimer;

         /* need to replace the timer */
         timer_free( timer->timer );
    }

    timer->timer    = timer_new(QEMU_CLOCK_REALTIME, SCALE_MS, callback, opaque );
    timer->callback = callback;
    timer->opaque   = opaque;

ReuseTimer:
    timer_mod( timer->timer, when );
}
示例#2
0
文件: mmul.c 项目: NatTuck/cakemark
int
main(int argc, char *argv[])
{
    pclu_context *pclu = pclu_create_context();
    printf("\n%s\n", pclu_context_info(pclu));

    matrix *aa = create_random_matrix(SIZE, SIZE);
    matrix *bb = create_identity_matrix(SIZE, SIZE);

#if PRINT_DATA
    printf("Matrix aa:\n");
    print_matrix(aa);
    printf("\n");

    printf("Matrix bb:\n");
    print_matrix(bb);
    printf("\n");
#endif

    timer* tt1 = timer_alloc();

    matrix *cc = create_matrix(SIZE, SIZE);
    matrix_multiply_cl(pclu, cc, aa, bb);
    
    double tm1 = timer_read(tt1);
    timer_free(tt1);
    
    printf("Matrix_multiply_cl took %.04f seconds.\n", tm1);

#if PRINT_DATA
    printf("Matrix cc:\n");
    print_matrix(cc);
    printf("\n");
#endif

    timer* tt = timer_alloc();
    check_result(aa, cc);
    
    double ct = timer_read(tt);
    timer_free(tt);
    
    printf("Check result took %.04f seconds.\n", ct);

    destroy_matrix(aa);
    destroy_matrix(bb);

    pclu_destroy_context(pclu);
    return 0;
}
示例#3
0
void
conn_remove(const Conn_t *connection)
{
  Conn_t *tmp, *prev;

  assert(connection != NULL);
  prev = NULL;
  tmp = connlist;
  while(tmp) {
    if (tmp == connection) {
      if (prev != NULL) {
	prev->next = tmp->next;
      } else {
	connlist = tmp->next;
      }
      if (connection->fd) {
	close(connection->fd);
	event_remove_fd(connection->fd);
      }
      if (connection->sfd) {
	event_remove_fd(connection->sfd);
	close(connection->sfd);
      }
      timer_free(&conn_unit, tmp->timer);
      mem_free(&conn_unit, tmp);
      return;
    }
    prev = tmp;
    tmp = tmp->next;
  }
}
示例#4
0
static void ipmi_bmc_extern_finalize(Object *obj)
{
    IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj);

    timer_del(ibe->extern_timer);
    timer_free(ibe->extern_timer);
}
示例#5
0
文件: qed.c 项目: MauroZurita/qemu
static void bdrv_qed_detach_aio_context(BlockDriverState *bs)
{
    BDRVQEDState *s = bs->opaque;

    qed_cancel_need_check_timer(s);
    timer_free(s->need_check_timer);
}
示例#6
0
文件: timer.c 项目: GNS3/dynamips
/* Enable a timer */
static timer_id timer_enable(timer_entry_t *timer)
{
   /* Allocate a new ID */
   TIMER_LOCK();
   timer->id = timer_alloc_id();

   /* Insert ID in hash table */
   if (hash_table_insert(timer_id_hash,&timer->id,timer) == -1) {
      TIMER_UNLOCK();
      free(timer);
      return(0);
   }

   /* Schedule event */
   if (timer_schedule(timer) == -1) {
      timer_free(timer,FALSE);
      timer = NULL;
      TIMER_UNLOCK();
      return(0);
   }

   /* Returns timer ID */
   TIMER_UNLOCK();      
   pthread_cond_signal(&timer->queue->schedule);
   return(timer->id);
}
static void
fifo_output_close(void *data)
{
	struct fifo_data *fd = (struct fifo_data *)data;

	timer_free(fd->timer);
}
示例#8
0
static void
_hwSensorClient_free( HwSensorClient*  cl )
{
    /* remove from sensors's list */
    if (cl->sensors) {
        HwSensorClient**  pnode = &cl->sensors->clients;
        for (;;) {
            HwSensorClient*  node = *pnode;
            if (node == NULL)
                break;
            if (node == cl) {
                *pnode = cl->next;
                break;
            }
            pnode = &node->next;
        }
        cl->next    = NULL;
        cl->sensors = NULL;
    }

    /* close QEMUD client, if any */
    if (cl->client) {
        qemud_client_close(cl->client);
        cl->client = NULL;
    }
    /* remove timer, if any */
    if (cl->timer) {
        timer_del(cl->timer);
        timer_free(cl->timer);
        cl->timer = NULL;
    }
    AFREE(cl);
}
示例#9
0
int timer_release(FAR struct posix_timer_s *timer)
{
  /* Some sanity checks */

  if (!timer)
    {
      return -EINVAL;
    }

  /* Release one reference to timer.  Don't delete the timer until the count
   * would decrement to zero.
   */

  if (timer->pt_crefs > 1)
    {
      timer->pt_crefs--;
      return 1;
    }

  /* Free the underlying watchdog instance (the timer will be canceled by the
   * watchdog logic before it is actually deleted)
   */

  (void)wd_delete(timer->pt_wdog);

  /* Release the timer structure */

  timer_free(timer);
  return OK;
}
示例#10
0
/*
 * Configure PORT_1A as data with PORT_1B as the valid signal. Ensure that the
 * receiver is ready using a channel end. Send a word of data, delay for a while
 * and send another word to ensure the valid signals are functioning.
 */
void port_test_output(chanend c)
{
  port p = port_enable(XS1_PORT_1A);
  port_set_buffered(p);
  port_set_transfer_width(p, 32);

  port p_ready = port_enable(XS1_PORT_1B);
  clock clk = clock_enable(XS1_CLKBLK_1);
  clock_start(clk);

  port_configure_out_strobed_master(p, p_ready, clk, 0);

  chan_input_word(c); // Wait for ack

  port_output(p, 0xfeedbeef);

  timer tmr = timer_alloc();
  timer_delay(tmr, 1000);
  timer_free(tmr);

  port_output(p, 0x12345678);

  chan_input_word(c); // Wait for ack

  port_disable(p);
  port_disable(p_ready);
  clock_disable(clk);

  // Get information about the tile/core running the server for debug messages
  unsigned tile_id = get_local_tile_id();
  unsigned core_id = get_logical_core_id();
  debug_printf("%x:%d: output done\n", tile_id, core_id);
}
示例#11
0
static void wdt_diag288_unrealize(DeviceState *dev, Error **errp)
{
    DIAG288State *diag288 = DIAG288(dev);

    timer_del(diag288->timer);
    timer_free(diag288->timer);
}
示例#12
0
文件: fork.c 项目: Mon-Ouie/benchmark
int main (int argc, char *argv[])  {
  timer *t = timer_alloc();
  recorder *parent_rec = recorder_alloc("parent.csv");
  recorder *child_rec = recorder_alloc("child.csv");

  pid_t pid;
  int status, i;

  for (i = 0; i < N; i++) {
    start_timer(t);
    pid = fork();

    if (pid == -1) {
      // erreur à l'exécution de fork
      perror("fork");
      return EXIT_FAILURE;
    }
    // pas d'erreur
    // BEGIN
    if (pid == 0) {
      // processus fils
      write_record(child_rec, i, stop_timer(t));

      recorder_free(child_rec);
      recorder_free(parent_rec);
      timer_free(t);

      return EXIT_SUCCESS;
    }
    else {
      // processus père
      write_record(parent_rec, i, stop_timer(t));
      pid = waitpid(pid, &status, 0);
      if (pid == -1) {
        perror("wait");
        return EXIT_FAILURE;
      }
    }
    // END
  }

  recorder_free(child_rec);
  recorder_free(parent_rec);
  timer_free(t);

  return EXIT_SUCCESS;
}
示例#13
0
文件: tnetw1130.c 项目: stweil/qemu
static void nic_cleanup(NetClientState *ncs)
{
#if 0
    tnetw1130_t *s = qemu_get_nic_opaque(ncs);
    timer_del(d->poll_timer);
    timer_free(d->poll_timer);
#endif
}
示例#14
0
/* destroy a timer */
static void throttle_timer_destroy(QEMUTimer **timer)
{
    assert(*timer != NULL);

    timer_del(*timer);
    timer_free(*timer);
    *timer = NULL;
}
示例#15
0
static void colo_compare_timer_del(CompareState *s)
{
    if (s->packet_check_timer) {
        timer_del(s->packet_check_timer);
        timer_free(s->packet_check_timer);
        s->packet_check_timer = NULL;
    }
 }
示例#16
0
文件: hid.c 项目: Aakriti/qemu
static void hid_del_idle_timer(HIDState *hs)
{
    if (hs->idle_timer) {
        timer_del(hs->idle_timer);
        timer_free(hs->idle_timer);
        hs->idle_timer = NULL;
    }
}
示例#17
0
文件: pipe.c 项目: pras710/qemu
static void
throttlePipe_close( void* opaque )
{
    ThrottlePipe* pipe = opaque;

    timer_del(pipe->timer);
    timer_free(pipe->timer);
    pingPongPipe_close(&pipe->pingpong);
}
示例#18
0
文件: ip6_icmp.c 项目: RodgerNO1/qemu
void icmp6_cleanup(Slirp *slirp)
{
    if (!slirp->in6_enabled) {
        return;
    }

    timer_del(slirp->ra_timer);
    timer_free(slirp->ra_timer);
}
示例#19
0
void end_resource_tracking(void)
{
	/* call everyone who tracks resources to let them know */
	auto_free();
	timer_free();

	/* decrement the tag counter */
	resource_tracking_tag--;
}
示例#20
0
static void balloon_stats_destroy_timer(VirtIOBalloon *s)
{
    if (balloon_stats_enabled(s)) {
        timer_del(s->stats_timer);
        timer_free(s->stats_timer);
        s->stats_timer = NULL;
        s->stats_poll_interval = 0;
    }
}
示例#21
0
static void virtio_rng_device_unrealize(DeviceState *dev, Error **errp)
{
    VirtIODevice *vdev = VIRTIO_DEVICE(dev);
    VirtIORNG *vrng = VIRTIO_RNG(dev);

    timer_del(vrng->rate_limit_timer);
    timer_free(vrng->rate_limit_timer);
    unregister_savevm(dev, "virtio-rng", vrng);
    virtio_cleanup(vdev);
}
示例#22
0
static void vhost_vsock_post_load_timer_cleanup(VHostVSock *vsock)
{
    if (!vsock->post_load_timer) {
        return;
    }

    timer_del(vsock->post_load_timer);
    timer_free(vsock->post_load_timer);
    vsock->post_load_timer = NULL;
}
示例#23
0
static void baum_close(struct CharDriverState *chr)
{
    BaumDriverState *baum = chr->opaque;

    timer_free(baum->cellCount_timer);
    if (baum->brlapi) {
        brlapi__closeConnection(baum->brlapi);
        g_free(baum->brlapi);
    }
    g_free(baum);
}
static void
sys_timer_free( SysTimer  timer )
{
    if (timer->timer) {
        timer_del( timer->timer );
        timer_free( timer->timer );
        timer->timer = NULL;
    }
    timer->next    = _s_free_timers;
    _s_free_timers = timer;
}
示例#25
0
void destroy_dst_blacklist()
{
	int r;
	struct dst_blst_entry** crt;
	struct dst_blst_entry* e;

	if (blst_timer_h){
		timer_del(blst_timer_h);
		timer_free(blst_timer_h);
		blst_timer_h=0;
	}
#ifdef BLST_LOCK_PER_BUCKET
	if (dst_blst_hash)
		for(r=0; r<DST_BLST_HASH_SIZE; r++)
			lock_destroy(&dst_blst_hash[r].lock);
#elif defined BLST_LOCK_SET
		if (blst_lock_set){
			lock_set_destroy(blst_lock_set);
			lock_set_dealloc(blst_lock_set);
			blst_lock_set=0;
		}
#else
	if (blst_lock){
		lock_destroy(blst_lock);
		lock_dealloc(blst_lock);
		blst_lock=0;
	}
#endif

	if (dst_blst_hash){
		for(r=0; r<DST_BLST_HASH_SIZE; r++){
			crt=&dst_blst_hash[r].first;
			while(*crt){
				e=*crt;
				*crt=(*crt)->next;
				blst_destroy_entry(e);
			}
		}
		shm_free(dst_blst_hash);
		dst_blst_hash=0;
	}
	if (blst_mem_used){
		shm_free((void*)blst_mem_used);
		blst_mem_used=0;
	}
#ifdef DST_BLACKLIST_HOOKS
	destroy_blacklist_hooks();
#endif

#ifdef USE_DST_BLACKLIST_STATS
	if (dst_blacklist_stats)
		shm_free(dst_blacklist_stats);
#endif
}
示例#26
0
文件: timer.c 项目: 010001111/darling
void
timer_close(timer_t *t)
{
	if (t == NULL) return;

	if (t->t_src != NULL) dispatch_source_cancel(t->t_src);

	/*
	 * We need to make sure that the source's event handler isn't currently running
	 * before we free the timer.  We let the source's queue do the actual free.
	 */
	dispatch_async(t->t_queue, ^{ timer_free(t); });
static void
openal_close(void *data)
{
	struct openal_data *od = data;

	timer_free(od->timer);
	alcMakeContextCurrent(od->context);
	alDeleteSources(1, &od->source);
	alDeleteBuffers(NUM_BUFFERS, od->buffers);
	alcDestroyContext(od->context);
	alcCloseDevice(od->device);
}
示例#28
0
文件: timer.c 项目: tyfkda/haribote
void timer_cancelall(FIFO* fifo) {
  int e = io_load_eflags();
  io_cli();
  for (int i = 0; i < MAX_TIMER; ++i) {
    TIMER* t = &timerctl.timers0[i];
    if (t->flags != 0 && t->flags2 != 0 && t->fifo == fifo) {
      timer_cancel(t);
      timer_free(t);
    }
  }
  io_store_eflags(e);
}
示例#29
0
w_err_t wind_timer_destroy(w_timer_s* timer)
{
    w_err_t err;
    WIND_ASSERT_RETURN(timer != W_NULL,W_ERR_PTR_NULL);
    WIND_ASSERT_RETURN(timer->obj.magic == WIND_TIMER_MAGIC,W_ERR_INVALID);    
    wind_notice("destroy timer:%s",timer->obj.name != W_NULL?timer->obj.name:"null");
    err = wind_obj_deinit(&timer->obj,WIND_TIMER_MAGIC,&timerlist);
    WIND_ASSERT_RETURN(err == W_ERR_OK,W_ERR_FAIL);
    if(IS_F_TIMER_POOL(timer))
        timer_free(timer);
    return W_ERR_OK;
}
示例#30
0
static void destroy_mod(void) {
	struct timer_action* a;
	DEBUG(MODULE_NAME": destroy: destroying, pid=%d\n", getpid());
	while (timer_actions) {
		a = timer_actions;
		if (a->link) {
			timer_del(a->link);
			timer_free(a->link);
		}
		timer_actions = a->next;
		shm_free(a);
	}
}