您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ timespec_sub函数代码示例

51自学网 2021-06-03 08:51:47
  C++
这篇教程C++ timespec_sub函数代码示例写得很实用,希望能帮到您。

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

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

示例1: ebbButton_init

/** @brief The LKM initialization function *  The static keyword restricts the visibility of the function to within this C file. The __init *  macro means that for a built-in driver (not a LKM) the function is only used at initialization *  time and that it can be discarded and its memory freed up after that point. In this example this *  function sets up the GPIOs and the IRQ *  @return returns 0 if successful */static int __init ebbButton_init (void){    int result = 0;    unsigned long IRQflags = IRQF_TRIGGER_RISING;      // The default is a rising-edge interrupt    printk(KERN_INFO "EBB Button: Initializing the EBB Button LKM/n");    sprintf(gpioName, "gpio%d", pressDetectInp);           // Create the gpio115 name for /sys/ebb/gpio115    // create the kobject sysfs entry at /sys/ebb -- probably not an ideal location!    ebb_kobj = kobject_create_and_add("ebb", kernel_kobj->parent); // kernel_kobj points to /sys/kernel    if (!ebb_kobj)    {        printk(KERN_ALERT "EBB Button: failed to create kobject mapping/n");        return -ENOMEM;    }    // add the attributes to /sys/ebb/ -- for example, /sys/ebb/gpio115/numberPresses    result = sysfs_create_group(ebb_kobj, &attr_group);    if (result)    {        printk(KERN_ALERT "EBB Button: failed to create sysfs group/n");        kobject_put(ebb_kobj);                          // clean up -- remove the kobject sysfs entry        return result;    }    getnstimeofday(&ts_last);                          // set the last time to be the current time    ts_diff = timespec_sub(ts_last, ts_last);          // set the initial time difference to be 0    // Set button outputs. It is a GPIO in input mode    result = gpio_request_array(btn_gpios, ARRAY_SIZE(btn_gpios));    if (result)    {        printk(KERN_ALERT "EBB Button: failed to request input array/n");        return result;    }    // Perform a quick test to see that the button is working as expected on LKM load    printk(KERN_INFO "EBB Button: The button state is currently: %d/n", gpio_get_value(pressDetectInp));    /// GPIO numbers and IRQ numbers are not the same! This function performs the mapping for us    irqNumber = gpio_to_irq(pressDetectInp);    printk(KERN_INFO "EBB Button: The button is mapped to IRQ: %d/n", irqNumber);    if (!isRising)                           // If the kernel parameter isRising=0 is supplied    {        IRQflags = IRQF_TRIGGER_FALLING;      // Set the interrupt to be on the falling edge    }    // This next call requests an interrupt line    result = request_irq(irqNumber,             // The interrupt number requested                    (irq_handler_t) ebbgpio_irq_handler, // The pointer to the handler function below                    IRQflags,              // Use the custom kernel param to set interrupt type                    "ebb_button_handler",  // Used in /proc/interrupts to identify the owner                    NULL);                 // The *dev_id for shared interrupt lines, NULL is okay    return result;}
开发者ID:mmpbel,项目名称:elka,代码行数:62,


示例2: update_cycles

static int update_cycles(struct reg_cycle_t * prev_cycle,		  	 struct reg_cycle_t * cur_cycle,			 ssize_t cur_qlen,			 bool enqueue){	ssize_t		end_len;        struct timespec	t_sub;        s64		t_sub_ns;	end_len = 0;	if (!enqueue) {		if (!cur_qlen)			return -1;		end_len = 1;	}        else if (cur_qlen == end_len) {                /* end cycle */		getnstimeofday(&cur_cycle->t_end);		t_sub = timespec_sub(cur_cycle->t_end, cur_cycle->t_last_start);		cur_cycle->sum_area += (ulong) cur_qlen * timespec_to_ns(&t_sub);		cur_cycle->t_last_start = cur_cycle->t_end;        } else {                /* middle cycle */                cur_cycle->t_last_start = cur_cycle->t_end;                getnstimeofday(&cur_cycle->t_end);                t_sub = timespec_sub(cur_cycle->t_end, cur_cycle->t_last_start);                cur_cycle->sum_area +=(ulong) cur_qlen * timespec_to_ns(&t_sub);        }        t_sub = timespec_sub(cur_cycle->t_end, prev_cycle->t_start);	t_sub_ns = timespec_to_ns(&t_sub);        cur_cycle->avg_len = (cur_cycle->sum_area + prev_cycle->sum_area);	if (t_sub_ns <= 0) {		LOG_ERR("Time delta is <= 0!");		return -1;	}	cur_cycle->avg_len /= (ulong) abs(t_sub_ns);	return 0;}
开发者ID:IRATI,项目名称:stack,代码行数:42,


示例3: omap3_enter_idle

/** * omap3_enter_idle - Programs OMAP3 to enter the specified state * @dev: cpuidle device * @state: The target state to be programmed * * Called from the CPUidle framework to program the device to the * specified target state selected by the governor. */static int omap3_enter_idle(struct cpuidle_device *dev,                            struct cpuidle_state *state){    struct omap3_processor_cx *cx = cpuidle_get_statedata(state);    struct timespec ts_preidle, ts_postidle, ts_idle;    u32 mpu_state = cx->mpu_state, core_state = cx->core_state;    u32 saved_mpu_state;    current_cx_state = *cx;    /* Used to keep track of the total time in idle */    getnstimeofday(&ts_preidle);    local_irq_disable();    local_fiq_disable();    if (!enable_off_mode) {        if (mpu_state < PWRDM_POWER_RET)            mpu_state = PWRDM_POWER_RET;        if (core_state < PWRDM_POWER_RET)            core_state = PWRDM_POWER_RET;    }    if (omap_irq_pending() || need_resched())        goto return_sleep_time;    saved_mpu_state = pwrdm_read_next_pwrst(mpu_pd);    pwrdm_set_next_pwrst(mpu_pd, mpu_state);    pwrdm_set_next_pwrst(core_pd, core_state);    if (cx->type == OMAP3_STATE_C1) {        pwrdm_for_each_clkdm(mpu_pd, _cpuidle_deny_idle);        pwrdm_for_each_clkdm(core_pd, _cpuidle_deny_idle);    }    /* Execute ARM wfi */    omap_sram_idle();    if (cx->type == OMAP3_STATE_C1) {        pwrdm_for_each_clkdm(mpu_pd, _cpuidle_allow_idle);        pwrdm_for_each_clkdm(core_pd, _cpuidle_allow_idle);    }    pwrdm_set_next_pwrst(mpu_pd, saved_mpu_state);return_sleep_time:    getnstimeofday(&ts_postidle);    ts_idle = timespec_sub(ts_postidle, ts_preidle);    local_irq_enable();    local_fiq_enable();    return ts_idle.tv_nsec / NSEC_PER_USEC + ts_idle.tv_sec * USEC_PER_SEC;}
开发者ID:Bdaman80,项目名称:BDA-ACTV,代码行数:62,


示例4: get_time

static char *get_time (void){  struct timespec TV2 = timespec_sub (current_timespec (), TV1);  uintmax_t s = TV2.tv_sec;  int ns = TV2.tv_nsec;  if (watch_not_started)    exit (EXIT_FAILURE);  /* call reset_watch first ! */  sprintf (time_string, "%"PRIuMAX".%0*d", s, LOG10_TIMESPEC_RESOLUTION, ns);  return time_string;}
开发者ID:0xAX,项目名称:emacs,代码行数:11,


示例5: print_result

static void print_result(u32 xfer_size, struct timespec lhs,			 struct timespec rhs){	long us;	struct timespec ts;	ts = timespec_sub(rhs, lhs);	us = ts.tv_sec*USEC_PER_SEC + ts.tv_nsec/NSEC_PER_USEC;	printk(KERN_INFO "%u: %lu/n", xfer_size, us);}
开发者ID:Android-Dongyf,项目名称:itop-kernel,代码行数:11,


示例6: omap3epfb_calc_latency

static unsigned long omap3epfb_calc_latency(struct omap3epfb_par *par,		int dest, int end){	BUG_ON(end < UPD_PRE_BLITTER || end > UPD_DSS_STARTING);	BUG_ON(dest < UPD_PB_LATENCY || dest > UPD_FULL_LATENCY);	par->update_timings[dest] = timespec_sub(par->update_timings[end],			par->update_timings[UPD_APP_REQUEST]);	return (par->update_timings[dest].tv_sec * 1000000 +			(par->update_timings[dest].tv_nsec / 1000));}
开发者ID:mali1,项目名称:NST-kernel,代码行数:11,


示例7: _omap_device_deactivate

/** * _omap_device_deactivate - decrease device readiness * @od: struct omap_device * * @ignore_lat: decrease to latency target (0) or full inactivity (1)? * * Decrease readiness of omap_device @od (thus increasing device * wakeup latency, but conserving power).  If @ignore_lat is * IGNORE_WAKEUP_LAT, make the omap_device fully inactive.  Otherwise, * if @ignore_lat is USE_WAKEUP_LAT, and the device's maximum wakeup * latency is less than the requested maximum wakeup latency, step * forwards in the omap_device_pm_latency table to ensure the device's * maximum wakeup latency is less than or equal to the requested * maximum wakeup latency.  Returns 0. */static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat){	struct timespec a, b, c;	dev_dbg(&od->pdev->dev, "omap_device: deactivating/n");	while (od->pm_lat_level < od->pm_lats_cnt) {		struct omap_device_pm_latency *odpl;		unsigned long long deact_lat = 0;		odpl = od->pm_lats + od->pm_lat_level;		if (!ignore_lat &&		    ((od->dev_wakeup_lat + odpl->activate_lat) >		     od->_dev_wakeup_lat_limit))			break;		read_persistent_clock(&a);		/* XXX check return code */		odpl->deactivate_func(od);		read_persistent_clock(&b);		c = timespec_sub(b, a);		deact_lat = timespec_to_ns(&c);		dev_dbg(&od->pdev->dev,			"omap_device: pm_lat %d: deactivate: elapsed time "			"%llu nsec/n", od->pm_lat_level, deact_lat);		if (deact_lat > odpl->deactivate_lat) {			odpl->deactivate_lat_worst = deact_lat;			if (odpl->flags & OMAP_DEVICE_LATENCY_AUTO_ADJUST) {				odpl->deactivate_lat = deact_lat;				dev_dbg(&od->pdev->dev,					"new worst case deactivate latency "					"%d: %llu/n",					od->pm_lat_level, deact_lat);			} else				dev_warn(&od->pdev->dev,					 "deactivate latency %d "					 "higher than exptected. (%llu > %d)/n",					 od->pm_lat_level, deact_lat,					 odpl->deactivate_lat);		}		od->dev_wakeup_lat += odpl->activate_lat;		od->pm_lat_level++;	}	return 0;}
开发者ID:lchao-bit,项目名称:linaro-kernel,代码行数:68,


示例8: bye

void bye(void){	clock_gettime(CLOCK_THREAD_CPUTIME_ID, &task_rst.t_whole_thread_finish);	task_rst.t_whole_thread_run = timespec_sub(&task_rst.t_whole_thread_finish, &task_rst.t_whole_thread_start);	printf("thread_total= %lld ns/t%3.2f%%/t%3.2f%%/nthread_run= %lld ns/t%3.2f%%/t%3.2f%%/n===end===/n", 			timespec_to_nsec(&task_rst.t_whole_thread_finish),			(double)timespec_to_nsec(&task_rst.t_whole_thread_finish) / (double)timespec_to_nsec(&task_rst.dl_budget) / (double)task_rst.correct_cnt * 100.0,			(double)timespec_to_nsec(&task_rst.t_whole_thread_finish) / (double)timespec_to_nsec(&task_rst.dl_period) / (double)task_rst.correct_cnt * 100.0,			timespec_to_nsec(&task_rst.t_whole_thread_run),			(double)timespec_to_nsec(&task_rst.t_whole_thread_run) / (double)timespec_to_nsec(&task_rst.dl_budget) / (double)task_rst.correct_cnt * 100.0,			(double)timespec_to_nsec(&task_rst.t_whole_thread_run) / (double)timespec_to_nsec(&task_rst.dl_period) / (double)task_rst.correct_cnt * 100.0);}
开发者ID:lookflying,项目名称:my-utility,代码行数:12,


示例9: calibrate

static unsigned long long calibrate(void){	struct timespec start, end, delta;	const int crunch_loops = 10000;	unsigned long long ns, lps;	unsigned long count;	struct timespec req;	char label[8];	int n;	count = 0;	clock_gettime(CLOCK_MONOTONIC, &start);	do_work(crunch_loops, &count);	clock_gettime(CLOCK_MONOTONIC, &end);		timespec_sub(&delta, &end, &start);	ns = delta.tv_sec * ONE_BILLION + delta.tv_nsec;	crunch_per_sec = (unsigned long long)((double)ONE_BILLION / (double)ns * crunch_loops);	for (n = 0; n < nrthreads; n++) {		sprintf(label, "t%d", n);		create_fifo_thread(threads[n], label, counts[n]);		sem_wait(&ready);	}	pthread_mutex_lock(&lock);	started = 1;	pthread_cond_broadcast(&barrier);	pthread_mutex_unlock(&lock);	req.tv_sec = 1;	req.tv_nsec = 0;	clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL);	for (n = 0, lps = 0; n < nrthreads; n++) {		lps += counts[n];		pthread_kill(threads[n], SIGDEMT);	}	atomic_set(&throttle, 1);	smp_wmb();	for (n = 0; n < nrthreads; n++) {		pthread_cancel(threads[n]);		pthread_join(threads[n], NULL);	}	started = 0;	atomic_set(&throttle, 0);	return lps;}
开发者ID:ChunHungLiu,项目名称:xenomai,代码行数:52,


示例10: write_heartbeat

// ------------------------------------------------------------------------------//   Write Heartbeat message// ------------------------------------------------------------------------------voidAutopilot_Interface::write_heartbeat(){  // --------------------------------------------------------------------------  //   PACK PAYLOAD  // --------------------------------------------------------------------------  // Allocate Space   mavlink_message_t msg;  mavlink_heartbeat_t heartbeat;  struct timespec t_now_rt,t_diff_rt;      uint64_t timestamp = get_time_usec();  // Pack the message  //mavlink_msg_heartbeat_pack(system_id, companion_id, &msg, mav_type, autopilot_id , base_mode, custom_mode, system_status)  heartbeat.type = MAV_TYPE_GCS;  heartbeat.autopilot = autopilot_id;  heartbeat.base_mode = base_mode;  heartbeat.system_status = system_status;  heartbeat.custom_mode = 0;    mavlink_msg_heartbeat_encode(system_id, companion_id, &msg, &heartbeat);  //mavlink_msg_heartbeat_encode(2, 125, &msg, &heartbeat);    // --------------------------------------------------------------------------  //   WRITE  // --------------------------------------------------------------------------  clock_gettime(CLOCK_REALTIME,&t_now_rt);    int len = write_message(msg);    timespec_sub(&t_diff_rt,&t_now_rt,&t_wrold_rt);  int64_t diff_rt = t_diff_rt.tv_sec*1e6 + t_diff_rt.tv_nsec/1e3;  //clock_gettime(CLOCK_REALTIME,&t_wrold_rt);  // With this command I obtained a DT with the writing time in the computation  t_wrold_rt.tv_nsec = t_now_rt.tv_nsec;  t_wrold_rt.tv_sec = t_now_rt.tv_sec;  //printf("hil_sensors_t DT : %lu us/r",diff_rt);    // check the write  if ( not len > 0 )    fprintf(stderr,"WARNING: could not send HIL_SENSORS /n");  //	else  //		printf("%lu POSITION_TARGET  = [ %f , %f , %f ] /n", write_count, position_target.x, position_target.y, position_target.z);  return;}
开发者ID:rt-2pm2,项目名称:routing,代码行数:55,


示例11: cal_dmaci_ampdu

struct timespec cal_dmaci_ampdu(int t){	struct timespec transmit={0},tmp1={0},tmp2={0},difs={0},dmaci={0};	ampdu[t].th = ampdu[t].tw;	if (timespec_compare(&ampdu[t].th,&ampdu[t].last_te)<0){		ampdu[t].th=ampdu[t].last_te;	}	transmit = cal_transmit_time(ampdu[t].len*ampdu[t].num,ampdu[t].rate);        difs.tv_sec =0;	difs.tv_nsec = CONST_TIME[t]*1000;	tmp1 = timespec_sub(ampdu[t].te,ampdu[t].th);	tmp2 = timespec_sub(tmp1,transmit);	dmaci = timespec_sub(tmp2,difs);	struct timespec ts_tmp;	getnstimeofday(&ts_tmp);	//checkpoint	if (dmaci.tv_sec < 0 || dmaci.tv_nsec < 0){		dmaci.tv_sec = 0;		dmaci.tv_nsec = 0;	}	return dmaci;}
开发者ID:chowp,项目名称:mac80211,代码行数:22,


示例12: kcylon_irq_handler

/** * @brief Kernel module interrupt handler *  Changes the button level when a button *  is pressed. Also it puts limits on the level. * * @param irq The irq number that identifies the button * @return returns IRQ_HANDLED which tells the kernel that this is a non-fatal interrupt */static irq_handler_t kcylon_irq_handler(unsigned int irq, void *dev_id, struct pt_regs *regs){	mutex_lock(&button_level_mutex);	button_level += button_direction;	if (button_level == 10 || button_level == -10)		button_direction *= -1;	mutex_unlock(&button_level_mutex);	getnstimeofday(&ts_current);	ts_diff = timespec_sub(ts_current, ts_last);	ts_last = ts_current;	printk(KERN_INFO "KCYLON: Interrupt received (button level %d)/n", button_level);	return (irq_handler_t) IRQ_HANDLED;}
开发者ID:benjamin-james,项目名称:kcylon,代码行数:21,


示例13: clockobj_convert_clocks

/* Conversion from CLOCK_COPPERPLATE to clk_id. */void clockobj_convert_clocks(struct clockobj *clkobj,			     const struct timespec *in,			     clockid_t clk_id,			     struct timespec *out){	struct timespec now, delta;	__RT(clock_gettime(CLOCK_COPPERPLATE, &now));	/* Offset from CLOCK_COPPERPLATE epoch. */	timespec_sub(&delta, in, &now);	/* Current time for clk_id. */	__RT(clock_gettime(clk_id, &now));	/* Absolute timeout again, clk_id-based this time. */	timespec_add(out, &delta, &now);}
开发者ID:Lmaths,项目名称:xenomai-forge,代码行数:16,


示例14: cmd_dispatch

/* * Process a single command. */staticintcmd_dispatch(char *cmd){	struct timespec before, after, duration;	char *args[MAXMENUARGS];	int nargs=0;	char *word;	char *context;	int i, result;	for (word = strtok_r(cmd, " /t", &context);	     word != NULL;	     word = strtok_r(NULL, " /t", &context)) {		if (nargs >= MAXMENUARGS) {			kprintf("Command line has too many words/n");			return E2BIG;		}		args[nargs++] = word;	}	if (nargs==0) {		return 0;	}	for (i=0; cmdtable[i].name; i++) {		if (*cmdtable[i].name && !strcmp(args[0], cmdtable[i].name)) {			KASSERT(cmdtable[i].func!=NULL);			gettime(&before);			result = cmdtable[i].func(nargs, args);			gettime(&after);			timespec_sub(&after, &before, &duration);			kprintf("Operation took %llu.%09lu seconds/n",				(unsigned long long) duration.tv_sec,				(unsigned long) duration.tv_nsec);			return result;		}	}	kprintf("%s: Command not found/n", args[0]);	return EINVAL;}
开发者ID:prasad223,项目名称:os161_Docker,代码行数:51,


示例15: timer_gettime

/* Get current value of timer TIMERID and store it in VLAUE.  */inttimer_gettime (timer_t timerid, struct itimerspec *value){  struct timer_node *timer;  struct timespec now, expiry;  int retval = -1, armed = 0, valid;  clock_t clock = 0;  pthread_mutex_lock (&__timer_mutex);  timer = timer_id2ptr (timerid);  valid = timer_valid (timer);  if (valid) {    armed = timer->armed;    expiry = timer->expirytime;    clock = timer->clock;    value->it_interval = timer->value.it_interval;  }  pthread_mutex_unlock (&__timer_mutex);  if (valid)    {      if (armed)	{	  clock_gettime (clock, &now);	  if (timespec_compare (&now, &expiry) < 0)	    timespec_sub (&value->it_value, &expiry, &now);	  else	    {	      value->it_value.tv_sec = 0;	      value->it_value.tv_nsec = 0;	    }	}      else	{	  value->it_value.tv_sec = 0;	  value->it_value.tv_nsec = 0;	}      retval = 0;    }  else    __set_errno (EINVAL);  return retval;}
开发者ID:RobbenBasten,项目名称:glibc,代码行数:49,


示例16: set_alarm

static voidset_alarm (void){  if (atimers)    {#ifdef HAVE_SETITIMER      struct itimerval it;#endif      struct timespec now, interval;#ifdef HAVE_ITIMERSPEC      if (0 <= timerfd || alarm_timer_ok)	{	  struct itimerspec ispec;	  ispec.it_value = atimers->expiration;	  ispec.it_interval.tv_sec = ispec.it_interval.tv_nsec = 0;# ifdef HAVE_TIMERFD	  if (timerfd_settime (timerfd, TFD_TIMER_ABSTIME, &ispec, 0) == 0)	    {	      add_timer_wait_descriptor (timerfd);	      return;	    }# endif	  if (alarm_timer_ok	      && timer_settime (alarm_timer, TIMER_ABSTIME, &ispec, 0) == 0)	    return;	}#endif      /* Determine interval till the next timer is ripe.	 Don't set the interval to 0; this disables the timer.  */      now = current_timespec ();      interval = (timespec_cmp (atimers->expiration, now) <= 0		  ? make_timespec (0, 1000 * 1000)		  : timespec_sub (atimers->expiration, now));#ifdef HAVE_SETITIMER      memset (&it, 0, sizeof it);      it.it_value = make_timeval (interval);      setitimer (ITIMER_REAL, &it, 0);#else /* not HAVE_SETITIMER */      alarm (max (interval.tv_sec, 1));#endif /* not HAVE_SETITIMER */    }}
开发者ID:GiantGeorgeGo,项目名称:emacs,代码行数:46,


示例17: cvtestthread

staticintcvtestthread(void *junk, unsigned long num){	int i;	volatile int j;	struct timespec ts1, ts2;	(void)junk;	for (i=0; i<NCVLOOPS; i++) {		lock_acquire(testlock);		while (testval1 != num) {			gettime(&ts1);			cv_wait(testcv, testlock);			gettime(&ts2);			/* ts2 -= ts1 */			timespec_sub(&ts2, &ts1, &ts2);			/* Require at least 2000 cpu cycles (we're 25mhz) */			if (ts2.tv_sec == 0 && ts2.tv_nsec < 40*2000) {				kprintf("cv_wait took only %u ns/n",					ts2.tv_nsec);				kprintf("That's too fast... you must be "					"busy-looping/n");				V(donesem);				thread_exit(0);			}		}		kprintf("Thread %lu/n", num);		testval1 = (testval1 + NTHREADS - 1)%NTHREADS;		/*		 * loop a little while to make sure we can measure the		 * time waiting on the cv.		 */		for (j=0; j<3000; j++);		cv_broadcast(testcv, testlock);		lock_release(testlock);	}	V(donesem);        return 0;}
开发者ID:hotwinter,项目名称:cse451-os161,代码行数:46,


示例18: omap2_enter_mpu_retention

static void omap2_enter_mpu_retention(void){	int only_idle = 0;	struct timespec ts_preidle, ts_postidle, ts_idle;	/* Putting MPU into the WFI state while a transfer is active	 * seems to cause the I2C block to timeout. Why? Good question. */	if (omap2_i2c_active())		return;	/* The peripherals seem not to be able to wake up the MPU when	 * it is in retention mode. */	if (omap2_allow_mpu_retention()) {		/* REVISIT: These write to reserved bits? */		omap2_prm_write_mod_reg(0xffffffff, CORE_MOD, PM_WKST1);		omap2_prm_write_mod_reg(0xffffffff, CORE_MOD, OMAP24XX_PM_WKST2);		omap2_prm_write_mod_reg(0xffffffff, WKUP_MOD, PM_WKST);		/* Try to enter MPU retention */		omap2_prm_write_mod_reg((0x01 << OMAP_POWERSTATE_SHIFT) |				  OMAP_LOGICRETSTATE_MASK,				  MPU_MOD, OMAP2_PM_PWSTCTRL);	} else {		/* Block MPU retention */		omap2_prm_write_mod_reg(OMAP_LOGICRETSTATE_MASK, MPU_MOD,						 OMAP2_PM_PWSTCTRL);		only_idle = 1;	}	if (omap2_pm_debug) {		omap2_pm_dump(only_idle ? 2 : 1, 0, 0);		getnstimeofday(&ts_preidle);	}	omap2_sram_idle();	if (omap2_pm_debug) {		unsigned long long tmp;		getnstimeofday(&ts_postidle);		ts_idle = timespec_sub(ts_postidle, ts_preidle);		tmp = timespec_to_ns(&ts_idle) * NSEC_PER_USEC;		omap2_pm_dump(only_idle ? 2 : 1, 1, tmp);	}}
开发者ID:kozmikkick,项目名称:eternityprj-kernel-endeavoru-128,代码行数:46,


示例19: omap3_enter_idle

/** * omap3_enter_idle - Programs OMAP3 to enter the specified state * @dev: cpuidle device * @state: The target state to be programmed * * Called from the CPUidle framework to program the device to the * specified target state selected by the governor. */static int omap3_enter_idle(struct cpuidle_device *dev,			struct cpuidle_state *state){	struct omap3_processor_cx *cx = cpuidle_get_statedata(state);	struct timespec ts_preidle, ts_postidle, ts_idle;	u32 mpu_state = cx->mpu_state, core_state = cx->core_state;	current_cx_state = *cx;	/* Used to keep track of the total time in idle */	getnstimeofday(&ts_preidle);	local_irq_disable();	local_fiq_disable();	pwrdm_set_next_pwrst(mpu_pd, mpu_state);	pwrdm_set_next_pwrst(core_pd, core_state);	//&*&*&*BC1_110630: add cpu idle control flag	if (omap_irq_pending() || need_resched() || omap3_idle_bm_check())  		goto return_sleep_time;//&*&*&*BC2_110630: add cpu idle control flag	if (cx->type == OMAP3_STATE_C1) {		pwrdm_for_each_clkdm(mpu_pd, _cpuidle_deny_idle);		pwrdm_for_each_clkdm(core_pd, _cpuidle_deny_idle);	}	/* Execute ARM wfi */	omap_sram_idle();	if (cx->type == OMAP3_STATE_C1) {		pwrdm_for_each_clkdm(mpu_pd, _cpuidle_allow_idle);		pwrdm_for_each_clkdm(core_pd, _cpuidle_allow_idle);	}return_sleep_time:	getnstimeofday(&ts_postidle);	ts_idle = timespec_sub(ts_postidle, ts_preidle);	local_irq_enable();	local_fiq_enable();	return ts_idle.tv_nsec / NSEC_PER_USEC + ts_idle.tv_sec * USEC_PER_SEC;}
开发者ID:UAVXP,项目名称:A10,代码行数:53,


示例20: delayacct_end

static void delayacct_end(struct timespec *start, struct timespec *end,				u64 *total, u32 *count){	struct timespec ts;	s64 ns;	unsigned long flags;	do_posix_clock_monotonic_gettime(end);	ts = timespec_sub(*end, *start);	ns = timespec_to_ns(&ts);	if (ns < 0)		return;	spin_lock_irqsave(&current->delays->lock, flags);	*total += ns;	(*count)++;	spin_unlock_irqrestore(&current->delays->lock, flags);}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:18,


示例21: _omap_device_deactivate

/** * _omap_device_deactivate - decrease device readiness * @od: struct omap_device * * @ignore_lat: decrease to latency target (0) or full inactivity (1)? * * Decrease readiness of omap_device @od (thus increasing device * wakeup latency, but conserving power).  If @ignore_lat is * IGNORE_WAKEUP_LAT, make the omap_device fully inactive.  Otherwise, * if @ignore_lat is USE_WAKEUP_LAT, and the device's maximum wakeup * latency is less than the requested maximum wakeup latency, step * forwards in the omap_device_pm_latency table to ensure the device's * maximum wakeup latency is less than or equal to the requested * maximum wakeup latency.  Returns 0. */static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat){	struct timespec a, b, c;	pr_debug("omap_device: %s: deactivating/n", od->pdev.name);	while (od->pm_lat_level < od->pm_lats_cnt) {		struct omap_device_pm_latency *odpl;		unsigned long long deact_lat = 0;		odpl = od->pm_lats + od->pm_lat_level;		if (!ignore_lat &&		    ((od->dev_wakeup_lat + odpl->activate_lat) >		     od->_dev_wakeup_lat_limit))			break;		getnstimeofday(&a);		/* XXX check return code */		odpl->deactivate_func(od);		getnstimeofday(&b);		c = timespec_sub(b, a);		deact_lat = timespec_to_ns(&c) * NSEC_PER_USEC;		pr_debug("omap_device: %s: pm_lat %d: deactivate: elapsed time "			 "%llu usec/n", od->pdev.name, od->pm_lat_level,			 deact_lat);		WARN(deact_lat > odpl->deactivate_lat, "omap_device: %s.%d: "		     "deactivate step %d took longer than expected "		     "(%llu > %d)/n", od->pdev.name, od->pdev.id,		     od->pm_lat_level, deact_lat, odpl->deactivate_lat);		od->dev_wakeup_lat += odpl->activate_lat;		od->pm_lat_level++;	}	return 0;}
开发者ID:Bdaman80,项目名称:BDA-ACTV,代码行数:57,


示例22: estimate_accuracy

static long estimate_accuracy(struct timespec *tv){	unsigned long ret;	struct timespec now;	/*	 * Realtime tasks get a slack of 0 for obvious reasons.	 */	if (rt_task(current))		return 0;	ktime_get_ts(&now);	now = timespec_sub(*tv, now);	ret = __estimate_accuracy(&now);	if (ret < current->timer_slack_ns)		return current->timer_slack_ns;	return ret;}
开发者ID:raddirad,项目名称:xeon_phi_kernel_integration,代码行数:19,


示例23: rtc_sync_save_delta

static void rtc_sync_save_delta(void){	struct rtc_time		rtc_time;	static time_t		rtc_time_t;	struct timespec		ts_system, ts_rtc;	getnstimeofday(&ts_system);	s3c_rtc_gettime(NULL, &rtc_time);	rtc_tm_to_time(&rtc_time, &rtc_time_t);	/* RTC precision is 1 second; adjust delta for avg 1/2 sec err */	set_normalized_timespec(&ts_rtc, rtc_time_t, NSEC_PER_SEC>>1);	ts_saved_delta = timespec_sub(ts_system, ts_rtc);#ifdef CONFIG_RTC_S3C_SYNC_SYSTEM_TIME_DEBUG	printk ("RTC_SYNC: save delta sec:%d nsec:%d/n", ts_saved_delta.tv_sec, ts_saved_delta.tv_nsec);#endif}
开发者ID:rubensollie,项目名称:Eclair-Kernel,代码行数:19,


示例24: clockobj_set_date

void clockobj_set_date(struct clockobj *clkobj, ticks_t ticks){	struct timespec now;	/*	 * XXX: we grab the lock to exclude other threads from reading	 * the clock offset while we update it, so that they either	 * compute against the old value, or the new one, but always	 * see a valid offset.	 */	read_lock_nocancel(&clkobj->lock);	__RT(clock_gettime(CLOCK_COPPERPLATE, &now));	__clockobj_ticks_to_timespec(clkobj, ticks, &clkobj->epoch);	timespec_sub(&clkobj->offset, &clkobj->epoch, &now);	read_unlock(&clkobj->lock);}
开发者ID:Lmaths,项目名称:xenomai-forge,代码行数:19,


示例25: tl_select_relay

void tl_select_relay(struct tr_info_list *list){	struct timespec tl_diff;	getrawmonotonic(&tl_end);	tl_diff = timespec_sub(tl_end, tl_start);	//printk("Topology learning time: %ld/n", timespec_to_ns(&tl_diff));	if(list == NULL){		printk("Select Relay error1/n");		return;	}	if(list->next == NULL){		printk("Select Relay error2/n");		return;	}	tr_info_list_arrangement(list);	if(MNPRELAY) mnp_relay(list);	else min_max_relay(list);}
开发者ID:yeonchul,项目名称:mac80211,代码行数:19,


示例26: omap3_enter_idle

/** * omap3_enter_idle - Programs OMAP3 to enter the specified state * @dev: cpuidle device * @state: The target state to be programmed * * Called from the CPUidle framework to program the device to the * specified target state selected by the governor. */static int omap3_enter_idle(struct cpuidle_device *dev,			struct cpuidle_state *state){	struct omap3_idle_statedata *cx = cpuidle_get_statedata(state);	struct timespec ts_preidle, ts_postidle, ts_idle;	u32 mpu_state = cx->mpu_state, core_state = cx->core_state;	/* Used to keep track of the total time in idle */	getnstimeofday(&ts_preidle);	local_irq_disable();	local_fiq_disable();	pwrdm_set_next_pwrst(mpu_pd, mpu_state);	pwrdm_set_next_pwrst(core_pd, core_state);	if (omap_irq_pending() || need_resched())		goto return_sleep_time;	/* Deny idle for C1 */	if (state == &dev->states[0]) {		pwrdm_for_each_clkdm(mpu_pd, _cpuidle_deny_idle);		pwrdm_for_each_clkdm(core_pd, _cpuidle_deny_idle);	}	/* Execute ARM wfi */	omap_sram_idle(false);	/* Re-allow idle for C1 */	if (state == &dev->states[0]) {		pwrdm_for_each_clkdm(mpu_pd, _cpuidle_allow_idle);		pwrdm_for_each_clkdm(core_pd, _cpuidle_allow_idle);	}return_sleep_time:	getnstimeofday(&ts_postidle);	ts_idle = timespec_sub(ts_postidle, ts_preidle);	local_irq_enable();	local_fiq_enable();	return ts_idle.tv_nsec / NSEC_PER_USEC + ts_idle.tv_sec * USEC_PER_SEC;}
开发者ID:0rt,项目名称:mpokang_kernel,代码行数:51,


示例27: frame_interval_monitor

/* * Monitor an averaged frame interval. If the average deviates too much * from the nominal frame rate, send the frame interval error event. The * frame intervals are averaged in order to quiet noise from * (presumably random) interrupt latency. */static void frame_interval_monitor(struct imx_media_fim *fim,				   struct timespec *ts){	unsigned long interval, error, error_avg;	bool send_event = false;	struct timespec diff;	if (!fim->enabled || ++fim->counter <= 0)		goto out_update_ts;	diff = timespec_sub(*ts, fim->last_ts);	interval = diff.tv_sec * 1000 * 1000 + diff.tv_nsec / 1000;	error = abs(interval - fim->nominal);	if (fim->tolerance_max && error >= fim->tolerance_max) {		dev_dbg(fim->sd->dev,			"FIM: %lu ignored, out of tolerance bounds/n",			error);		fim->counter--;		goto out_update_ts;	}	fim->sum += error;	if (fim->counter == fim->num_avg) {		error_avg = DIV_ROUND_CLOSEST(fim->sum, fim->num_avg);		if (error_avg > fim->tolerance_min)			send_event = true;		dev_dbg(fim->sd->dev, "FIM: error: %lu usec%s/n",			error_avg, send_event ? " (!!!)" : "");		fim->counter = 0;		fim->sum = 0;	}out_update_ts:	fim->last_ts = *ts;	if (send_event)		send_fim_event(fim, error_avg);}
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:48,



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


C++ timespec_to_ktime函数代码示例
C++ times函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。