コード例 #1
0
ファイル: ctl.c プロジェクト: AhmadTux/freebsd
static int
prof_active_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
    void *newp, size_t newlen)
{
	int ret;
	bool oldval;

	if (config_prof == false)
		return (ENOENT);

	malloc_mutex_lock(&ctl_mtx); /* Protect opt_prof_active. */
	oldval = opt_prof_active;
	if (newp != NULL) {
		/*
		 * The memory barriers will tend to make opt_prof_active
		 * propagate faster on systems with weak memory ordering.
		 */
		mb_write();
		WRITE(opt_prof_active, bool);
		mb_write();
	}
	READ(oldval, bool);

	ret = 0;
label_return:
	malloc_mutex_unlock(&ctl_mtx);
	return (ret);
}
コード例 #2
0
/* write various output files */
static void at_output(at_t *at, llong_t step,
      int ib, double invw, double t1, double t2, double Eav,
      bool bfirst, bool blast, bool btr, bool bflush)
{
   bool btrace;

   /* write the trace file */
   if (at->nsttrace > 0)
      btrace = (step % at->nsttrace == 0) || bfirst || blast;
   else /* tracing is disabled if at->nsttrace == 0 */
      btrace = (at->nsttrace == 0) ? btr : 0;

   if(bflush)
      at->log->flags |= LOG_FLUSHAFTER;
   else
      at->log->flags ^= LOG_FLUSHAFTER;

   if (btrace) {
      log_printf(at->log, "%10.3f %5d %10.6f %12.3f %12.3f %10.6f %8.3f %8.5f",
	    step * at->tmstep, ib, t2 - t1, at->Ea, Eav, at->beta, t1, invw);    
      log_printf(at->log, "\n");
   }

   if (at_doevery(step, at->mb->av_nstsave, bfirst, blast)) { /* save averages */
      mb_write(at->mb);
      mb_wze(at->mb, NULL);
      mtsave(at->rng_file);
   }
   if (at_doevery(step, at->mb->eh_nstsave, bfirst, blast)) { /* save energy histograms */
      mb_eh_writebin(at->mb, at->mb->eh_file, 0);
      mb_eh_recon(at->mb, NULL);
   }
}
コード例 #3
0
ファイル: test_mailbox.c プロジェクト: elambert/honeycomb
static void
act_callback(mb_id_t mbid, mb_action_t act)
{
    unsigned long mbcheck = MB_CHECK;

    switch (act) {
    case ACT_INIT:
       if (mb_setstate(mbid, SRV_READY) == MB_ERROR) {
           cm_trace(CM_TRACE_LEVEL_ERROR,
                    "failed to set state SRV_READY");
           exit(1);
       }
       break;

    case ACT_START:
       if (mb_write(mbid, &mbcheck, MB_OFFSET, sizeof(mbcheck)) == MB_ERROR) {           cm_trace(CM_TRACE_LEVEL_ERROR, 
                    "mb_write failed: %s", strerror(errno));
           exit(1);
       } 
       if (mb_setstate(mbid, SRV_RUNNING) == MB_ERROR) {
           cm_trace(CM_TRACE_LEVEL_ERROR,
                    "failed to set state SRV_RUNNING");
           exit(1);
       }
       break;

    case ACT_STOP:
       if (mb_setstate(mbid, SRV_READY) == MB_ERROR) {
           cm_trace(CM_TRACE_LEVEL_ERROR,
                    "failed to set state SRV_READY");
           exit(1);
       }
       break;

    case ACT_DESTROY:
       exit(0);
       break;

    default:
       cm_trace(CM_TRACE_LEVEL_ERROR,
                "act_callback unknown action %d", act);
       exit(1);
       break;
    }
}