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

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

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

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

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

示例1: log_timing

// TODO: print values to proc fileint log_timing(int type){    s64 ns_time, ns_diff;    struct timeval current_time;    //static inline s64 timeval_to_ns(const struct timeval *tv)    //extern void do_gettimeofday(struct timeval *tv);    do_gettimeofday(&current_time);    ns_time = timeval_to_ns(&current_time);    if( (type != TIMING_TX_START) && (type != TIMING_RX_START) ) {        if( type <= ((TIMING_NUM_ELEMENTS - 1)/2) )             ns_diff = ns_time - __timing_array[TIMING_TX_START];        else             ns_diff = ns_time - __timing_array[TIMING_RX_START];        __timing_array[type] += ns_diff;    } else {        __timing_array[type] = ns_time;        if( type == TIMING_TX_START )            __timing_array[TIMING_TX_PACKETS] += 1;        else if( type == TIMING_RX_START )            __timing_array[TIMING_RX_PACKETS] += 1;    }    return 0;}
开发者ID:UW-WiNGS,项目名称:virtnet,代码行数:30,


示例2: time_to_ns

/* return the current time in nanoseconds */static int64_t time_to_ns(void){    struct timeval tv;    do_gettimeofday(&tv);        return timeval_to_ns(&tv);}
开发者ID:hellove1985,项目名称:ZT-180,代码行数:9,


示例3: swsusp_show_speed

void swsusp_show_speed(struct timeval *start, struct timeval *stop,			unsigned nr_pages, char *msg){	s64 elapsed_centisecs64;	int centisecs;	int k;	int kps;	elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);	do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);	centisecs = elapsed_centisecs64;	if (centisecs == 0)		centisecs = 1;	/* avoid div-by-zero */	k = nr_pages * (PAGE_SIZE / 1024);	kps = (k * 100) / centisecs;	printk("%s %d kbytes in %d.%02d seconds (%d.%02d MB/s)/n", msg, k,			centisecs / 100, centisecs % 100,			kps / 1000, (kps % 1000) / 10);}
开发者ID:xiandaicxsj,项目名称:copyKvm,代码行数:19,


示例4: set_cpu_itimer

static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,			   const struct itimerval *const value,			   struct itimerval *const ovalue){	cputime_t cval, nval, cinterval, ninterval;	s64 ns_ninterval, ns_nval;	u32 error, incr_error;	struct cpu_itimer *it = &tsk->signal->it[clock_id];	nval = timeval_to_cputime(&value->it_value);	ns_nval = timeval_to_ns(&value->it_value);	ninterval = timeval_to_cputime(&value->it_interval);	ns_ninterval = timeval_to_ns(&value->it_interval);	error = cputime_sub_ns(nval, ns_nval);	incr_error = cputime_sub_ns(ninterval, ns_ninterval);	spin_lock_irq(&tsk->sighand->siglock);	cval = it->expires;	cinterval = it->incr;	if (!cputime_eq(cval, cputime_zero) ||	    !cputime_eq(nval, cputime_zero)) {		if (cputime_gt(nval, cputime_zero))			nval = cputime_add(nval, cputime_one_jiffy);		set_process_cpu_timer(tsk, clock_id, &nval, &cval);	}	it->expires = nval;	it->incr = ninterval;	it->error = error;	it->incr_error = incr_error;	trace_itimer_state(clock_id == CPUCLOCK_VIRT ?			   ITIMER_VIRTUAL : ITIMER_PROF, value, nval);	spin_unlock_irq(&tsk->sighand->siglock);	if (ovalue) {		cputime_to_timeval(cval, &ovalue->it_value);		cputime_to_timeval(cinterval, &ovalue->it_interval);	}}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:41,


示例5: get_dilated_time

void get_dilated_time(struct task_struct * task,struct timeval* tv){	s64 temp_past_physical_time;	do_gettimeofday(tv);	if(task->virt_start_time != 0){		if (task->group_leader != task) { //use virtual time of the leader thread                       	task = task->group_leader;        }		s64 now = timeval_to_ns(tv);		s32 rem;		s64 real_running_time;		s64 dilated_running_time;		//spin_lock(&task->dialation_lock);		if(task->freeze_time == 0){			real_running_time = now - task->virt_start_time;		}		else{			real_running_time = task->freeze_time - task->virt_start_time;		}		//real_running_time = now - task->virt_start_time;		//if (task->freeze_time != 0)		//	temp_past_physical_time = task->past_physical_time + (now - task->freeze_time);		//else		temp_past_physical_time = task->past_physical_time;		if (task->dilation_factor > 0) {			dilated_running_time = div_s64_rem( (real_running_time - temp_past_physical_time)*1000 ,task->dilation_factor,&rem) + task->past_virtual_time;			now = dilated_running_time + task->virt_start_time;		}		else if (task->dilation_factor < 0) {			dilated_running_time = div_s64_rem( (real_running_time - temp_past_physical_time)*(task->dilation_factor*-1),1000,&rem) + task->past_virtual_time;			now =  dilated_running_time + task->virt_start_time;		}		else {			dilated_running_time = (real_running_time - temp_past_physical_time) + task->past_virtual_time;			now = dilated_running_time + task->virt_start_time;		}				if(task->freeze_time == 0){			task->past_physical_time = real_running_time;			task->past_virtual_time = dilated_running_time;		}		//spin_unlock(&task->dialation_lock);		*tv = ns_to_timeval(now);	}	return;}
开发者ID:Vignesh2208,项目名称:Awlsim_Ins,代码行数:51,


示例6: swsusp_show_speed

/** * swsusp_show_speed - Print time elapsed between two events during hibernation. * @start: Starting event. * @stop: Final event. * @nr_pages: Number of memory pages processed between @start and @stop. * @msg: Additional diagnostic message to print. */void swsusp_show_speed(struct timeval *start, struct timeval *stop,			unsigned nr_pages, char *msg){	u64 elapsed_centisecs64;	unsigned int centisecs;	unsigned int k;	unsigned int kps;	elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);	/*	 * If "(s64)elapsed_centisecs64 < 0", it will print long elapsed time,	 * it is obvious enough for what went wrong.	 */	do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);	centisecs = elapsed_centisecs64;	if (centisecs == 0)		centisecs = 1;	/* avoid div-by-zero */	k = nr_pages * (PAGE_SIZE / 1024);	kps = (k * 100) / centisecs;	printk(KERN_INFO "PM: %s %u kbytes in %u.%02u seconds (%u.%02u MB/s)/n",			msg, k,			centisecs / 100, centisecs % 100,			kps / 1000, (kps % 1000) / 10);}
开发者ID:3null,项目名称:linux,代码行数:31,


示例7: do_p2m

static voiddo_p2m(unsigned long (*conv)(unsigned long),       const char* msg, const char* prefix,        unsigned long start_gpfn, unsigned end_gpfn, unsigned long stride){	struct timeval before_tv;	struct timeval after_tv;	unsigned long gpfn;	unsigned long mfn;	unsigned long count;	s64 nsec;	count = 0;	do_gettimeofday(&before_tv);	for (gpfn = start_gpfn; gpfn < end_gpfn; gpfn += stride) {		mfn = (*conv)(gpfn);		count++;	}	do_gettimeofday(&after_tv);	nsec = timeval_to_ns(&after_tv) - timeval_to_ns(&before_tv);	printk("%s stride %4ld %s: %9ld / %6ld = %5ld nsec/n",	       msg, stride, prefix,	       nsec, count, nsec/count);}
开发者ID:Angel666,项目名称:android_hardware_intel,代码行数:24,


示例8: __copy_timestamp

static void __copy_timestamp(struct vb2_buffer *vb, const void *pb){	const struct v4l2_buffer *b = pb;	struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);	struct vb2_queue *q = vb->vb2_queue;	if (q->is_output) {		/*		 * For output buffers copy the timestamp if needed,		 * and the timecode field and flag if needed.		 */		if (q->copy_timestamp)			vb->timestamp = timeval_to_ns(&b->timestamp);		vbuf->flags |= b->flags & V4L2_BUF_FLAG_TIMECODE;		if (b->flags & V4L2_BUF_FLAG_TIMECODE)			vbuf->timecode = b->timecode;	}};
开发者ID:513855417,项目名称:linux,代码行数:18,


示例9: check_format

static int check_format(char *string) {	char *str;	if(string[0] != '+') {		printf("invalid format string use '+%%N'/n");		return -1;	}	if(NULL != (str = get_next_key(string))) {		switch(str[0]) {		case 'N': {			struct timeval tv;			time64_t ns;			ktime_get_timeval(&tv);			ns = timeval_to_ns(&tv);			printf("%lld/n", ns % MAX_NANOSECONDS);			break;		}		default:			break;		}	}	return 0;}
开发者ID:AleksandraButrova,项目名称:embox,代码行数:23,


示例10: try_to_freeze_tasks

static int try_to_freeze_tasks(bool user_only){	struct task_struct *g, *p;	unsigned long end_time;	unsigned int todo;	bool wq_busy = false;	struct timeval start, end;	u64 elapsed_csecs64;	unsigned int elapsed_csecs;	bool wakeup = false;	do_gettimeofday(&start);	end_time = jiffies + TIMEOUT;	if (!user_only)		freeze_workqueues_begin();	while (true) {		todo = 0;		read_lock(&tasklist_lock);		do_each_thread(g, p) {			if (p == current || !freeze_task(p))				continue;			/*			 * Now that we've done set_freeze_flag, don't			 * perturb a task in TASK_STOPPED or TASK_TRACED.			 * It is "frozen enough".  If the task does wake			 * up, it will immediately call try_to_freeze.			 *			 * Because freeze_task() goes through p's			 * scheduler lock after setting TIF_FREEZE, it's			 * guaranteed that either we see TASK_RUNNING or			 * try_to_stop() after schedule() in ptrace/signal			 * stop sees TIF_FREEZE.			 */			if (!task_is_stopped_or_traced(p) &&			    !freezer_should_skip(p))				todo++;		} while_each_thread(g, p);		read_unlock(&tasklist_lock);		if (!user_only) {			wq_busy = freeze_workqueues_busy();			todo += wq_busy;		}		if (!todo || time_after(jiffies, end_time))			break;		if (pm_wakeup_pending()) {			wakeup = true;			break;		}		/*		 * We need to retry, but first give the freezing tasks some		 * time to enter the regrigerator.		 */		msleep(10);	}	do_gettimeofday(&end);	elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);	do_div(elapsed_csecs64, NSEC_PER_SEC / 100);	elapsed_csecs = elapsed_csecs64;	if (todo) {		printk("/n");		printk(KERN_ERR "Freezing of tasks %s after %d.%02d seconds "		       "(%d tasks refusing to freeze, wq_busy=%d):/n",		       wakeup ? "aborted" : "failed",		       elapsed_csecs / 100, elapsed_csecs % 100,		       todo - wq_busy, wq_busy);		read_lock(&tasklist_lock);		do_each_thread(g, p) {			if (!wakeup && !freezer_should_skip(p) &&			    p != current && freezing(p) && !frozen(p))				sched_show_task(p);		} while_each_thread(g, p);		read_unlock(&tasklist_lock);	} else {
开发者ID:StefanPeter,项目名称:linux-2.6-guard,代码行数:84,


示例11: try_to_freeze_tasks

static int try_to_freeze_tasks(int freeze_user_space){	struct task_struct *g, *p;	unsigned long end_time;	unsigned int todo;	struct timeval start, end;	s64 elapsed_csecs64;	unsigned int elapsed_csecs;	do_gettimeofday(&start);	end_time = jiffies + TIMEOUT;	do {		todo = 0;		read_lock(&tasklist_lock);		do_each_thread(g, p) {			if (frozen(p) || !freezeable(p))				continue;			if (p->state == TASK_TRACED && frozen(p->parent)) {				cancel_freezing(p);				continue;			}			if (!freeze_task(p, freeze_user_space))				continue;			if (!freezer_should_skip(p))				todo++;		} while_each_thread(g, p);		read_unlock(&tasklist_lock);		yield();			/* Yield is okay here */		if (time_after(jiffies, end_time))			break;	} while (todo);	do_gettimeofday(&end);	elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);	do_div(elapsed_csecs64, NSEC_PER_SEC / 100);	elapsed_csecs = elapsed_csecs64;	if (todo) {		/* This does not unfreeze processes that are already frozen		 * (we have slightly ugly calling convention in that respect,		 * and caller must call thaw_processes() if something fails),		 * but it cleans up leftover PF_FREEZE requests.		 */		printk("/n");		printk(KERN_ERR "Freezing of tasks failed after %d.%02d seconds "				"(%d tasks refusing to freeze):/n",				elapsed_csecs / 100, elapsed_csecs % 100, todo);		show_state();		read_lock(&tasklist_lock);		do_each_thread(g, p) {			task_lock(p);			if (freezing(p) && !freezer_should_skip(p))				printk(KERN_ERR " %s/n", p->comm);			cancel_freezing(p);			task_unlock(p);		} while_each_thread(g, p);		read_unlock(&tasklist_lock);	} else {
开发者ID:acassis,项目名称:emlinux-ssd1935,代码行数:62,


示例12: msleep

			break;		if (pm_wakeup_pending()) {			wakeup = true;			break;		}		/*		 * We need to retry, but first give the freezing tasks some		 * time to enter the regrigerator.		 */		msleep(10);	}	do_gettimeofday(&end);	elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);	do_div(elapsed_csecs64, NSEC_PER_SEC / 100);	elapsed_csecs = elapsed_csecs64;	if (todo) {		/* This does not unfreeze processes that are already frozen		 * (we have slightly ugly calling convention in that respect,		 * and caller must call thaw_processes() if something fails),		 * but it cleans up leftover PF_FREEZE requests.		 */		if(wakeup) {			printk("/n");			printk(KERN_ERR "Freezing of %s aborted (%s)/n",					user_only ? "user space " : "tasks ", q ? q->comm : "NONE");		}		else {
开发者ID:mikebarr007,项目名称:BeastMode-Kernel-N900P,代码行数:31,


示例13: timeval_subtract

static inline long long timeval_subtract(struct timeval *a, struct timeval *b){	return timeval_to_ns(a) - timeval_to_ns(b);}
开发者ID:dillonhicks,项目名称:ipymake,代码行数:4,


示例14: mali_dvfs_policy_realize

//.........这里部分代码省略.........#if CLOCK_TUNING_TIME_DEBUG	struct timeval start;	struct timeval stop;	unsigned int elapse_time;	do_gettimeofday(&start);#endif	u32 window_render_fps;	if (NULL == gpu_clk) {		MALI_DEBUG_PRINT(2, ("Enable DVFS but patform doesn't Support freq change. /n"));		return;	}	window_render_fps = calculate_window_render_fps(time_period);	current_fps = window_render_fps;	current_gpu_util = data->utilization_gpu;	/* Get the specific under_perform_boundary_value and over_perform_boundary_value */	if ((mali_desired_fps <= current_fps) && (current_fps < mali_max_system_fps)) {		under_perform_boundary_value = MALI_PERCENTAGE_TO_UTILIZATION_FRACTION(90);		over_perform_boundary_value = MALI_PERCENTAGE_TO_UTILIZATION_FRACTION(70);	} else if ((mali_fps_step1 <= current_fps) && (current_fps < mali_desired_fps)) {		under_perform_boundary_value = MALI_PERCENTAGE_TO_UTILIZATION_FRACTION(55);		over_perform_boundary_value = MALI_PERCENTAGE_TO_UTILIZATION_FRACTION(35);	} else if ((mali_fps_step2 <= current_fps) && (current_fps < mali_fps_step1)) {		under_perform_boundary_value = MALI_PERCENTAGE_TO_UTILIZATION_FRACTION(70);		over_perform_boundary_value = MALI_PERCENTAGE_TO_UTILIZATION_FRACTION(50);	} else {		under_perform_boundary_value = MALI_PERCENTAGE_TO_UTILIZATION_FRACTION(55);		over_perform_boundary_value = MALI_PERCENTAGE_TO_UTILIZATION_FRACTION(35);	}	MALI_DEBUG_PRINT(5, ("Using ARM power policy: gpu util = %d /n", current_gpu_util));	MALI_DEBUG_PRINT(5, ("Using ARM power policy: under_perform = %d,  over_perform = %d /n", under_perform_boundary_value, over_perform_boundary_value));	MALI_DEBUG_PRINT(5, ("Using ARM power policy: render fps = %d,  pressure render fps = %d /n", current_fps, window_render_fps));	/* Get current clock value */	cur_clk_step = mali_gpu_get_freq();	/* Consider offscreen */	if (0 == current_fps) {		/* GP or PP under perform, need to give full power */		if (current_gpu_util > over_perform_boundary_value) {			if (cur_clk_step != gpu_clk->num_of_steps - 1) {				clock_changed = true;				clock_step = gpu_clk->num_of_steps - 1;			}		}		/* If GPU is idle, use lowest power */		if (0 == current_gpu_util) {			if (cur_clk_step != 0) {				clock_changed = true;				clock_step = 0;			}		}		goto real_setting;	}	/* 2. Calculate target clock if the GPU clock can be tuned */	if (-1 != cur_clk_step) {		int target_clk_mhz = -1;		mali_bool pick_clock_up = MALI_TRUE;		if (current_gpu_util > under_perform_boundary_value) {			/* when under perform, need to consider the fps part */			target_clk_mhz = gpu_clk->item[cur_clk_step].clock * current_gpu_util * mali_desired_fps / under_perform_boundary_value / current_fps;			pick_clock_up = MALI_TRUE;		} else if (current_gpu_util < over_perform_boundary_value) {			/* when over perform, did't need to consider fps, system didn't want to reach desired fps */			target_clk_mhz = gpu_clk->item[cur_clk_step].clock * current_gpu_util / under_perform_boundary_value;			pick_clock_up = MALI_FALSE;		}		if (-1 != target_clk_mhz) {			clock_changed = mali_pickup_closest_avail_clock(target_clk_mhz, pick_clock_up);		}	}real_setting:	if (clock_changed) {		mali_gpu_set_freq(clock_step);		_mali_osk_profiling_add_event(MALI_PROFILING_EVENT_TYPE_SINGLE |					      MALI_PROFILING_EVENT_CHANNEL_GPU |					      MALI_PROFILING_EVENT_REASON_SINGLE_GPU_FREQ_VOLT_CHANGE,					      gpu_clk->item[clock_step].clock,					      gpu_clk->item[clock_step].vol / 1000,					      0, 0, 0);	}#if CLOCK_TUNING_TIME_DEBUG	do_gettimeofday(&stop);	elapse_time = timeval_to_ns(&stop) - timeval_to_ns(&start);	MALI_DEBUG_PRINT(2, ("Using ARM power policy:  eclapse time = %d/n", elapse_time));#endif}
开发者ID:CM13-HI6210SFT,项目名称:hisi_kernel_3.10.86_hi6210sft,代码行数:101,


示例15: try_to_freeze_tasks

static int try_to_freeze_tasks(bool user_only){	struct task_struct *g, *p;#ifdef CONFIG_SEC_PM_DEBUG	struct task_struct *q;#endif	unsigned long end_time;	unsigned int todo;	bool wq_busy = false;	struct timeval start, end;	u64 elapsed_msecs64;	unsigned int elapsed_msecs;	bool wakeup = false;	int sleep_usecs = USEC_PER_MSEC;	do_gettimeofday(&start);	end_time = jiffies + msecs_to_jiffies(freeze_timeout_msecs);	if (!user_only)		freeze_workqueues_begin();	while (true) {		todo = 0;		read_lock(&tasklist_lock);		do_each_thread(g, p) {			if (p == current || !freeze_task(p))				continue;			if (!freezer_should_skip(p)) {				todo++;#ifdef CONFIG_SEC_PM_DEBUG				q = p;#endif			}		} while_each_thread(g, p);		read_unlock(&tasklist_lock);		if (!user_only) {			wq_busy = freeze_workqueues_busy();			todo += wq_busy;		}		if (!todo || time_after(jiffies, end_time))			break;		if (pm_wakeup_pending()) {			wakeup = true;			break;		}		/*		 * We need to retry, but first give the freezing tasks some		 * time to enter the refrigerator.  Start with an initial		 * 1 ms sleep followed by exponential backoff until 8 ms.		 */		usleep_range(sleep_usecs / 2, sleep_usecs);		if (sleep_usecs < 8 * USEC_PER_MSEC)			sleep_usecs *= 2;	}	do_gettimeofday(&end);	elapsed_msecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);	do_div(elapsed_msecs64, NSEC_PER_MSEC);	elapsed_msecs = elapsed_msecs64;	if (todo) {		printk("/n");		printk(KERN_ERR "Freezing of tasks %s after %d.%03d seconds "		       "(%d tasks refusing to freeze, wq_busy=%d):/n",		       wakeup ? "aborted" : "failed",		       elapsed_msecs / 1000, elapsed_msecs % 1000,		       todo - wq_busy, wq_busy);#ifdef CONFIG_SEC_PM_DEBUG		if (wakeup) {			printk(KERN_ERR "Freezing of %s aborted (%d) (%s)/n",					user_only ? "user space " : "tasks ",					q ? q->pid : 0, q ? q->comm : "NONE");		}#endif		if (!wakeup) {			read_lock(&tasklist_lock);			do_each_thread(g, p) {				if (p != current && !freezer_should_skip(p)				    && freezing(p) && !frozen(p))					sched_show_task(p);			} while_each_thread(g, p);			read_unlock(&tasklist_lock);		}	} else {
开发者ID:StarKissed,项目名称:Note-4-AEL-Kernel,代码行数:92,


示例16: gaole_test_thread

static int gaole_test_thread(void *data){	int i,j,k;		static struct timeval start_time;	static struct timeval stop_time;	static signed long long elapsed_time;	struct sched_param param = {.sched_priority = 90};	/*set the thread as a real time thread, and its priority is 90*/	sched_setscheduler(current, SCHED_RR, &param);		for(i=0;i<16;i++){		data_send_ptr[i] = kmalloc(SEND_BUF_LEN,GFP_KERNEL);		if (NULL == data_send_ptr[i])		{			SDIOTRAN_ERR("kmalloc send buf%d err!!!",i);			return -1;		}				SDIOTRAN_DEBUG("kmalloc send buf%d ok!!!",i);		for(j=0,k=0;j<SEND_BUF_LEN;j++,k++)			*(data_send_ptr[i]+j) = ((k+i)<=255?(k+i):(k=0,k+i));		}	//set_blklen(1); 	while(1)	{		for(i=0;i<16;i++)		{			do_gettimeofday(&start_time);						for(j=0;j<100;j++)				test_sdio_send_func(i,data_send_ptr[i]);			do_gettimeofday(&stop_time);			elapsed_time = timeval_to_ns(&stop_time) - timeval_to_ns(&start_time);			SDIOTRAN_ERR("Chn %d test elapsed_time is %lld!!!",i,elapsed_time);			elapsed_time = 0;		}		break;				SDIOTRAN_ERR("sdio test write finish!!!");			}			return 0;}void gaole_creat_test(void){	struct task_struct * task;	task = kthread_create(gaole_test_thread, NULL, "GaoleTest");	if(0 != task)		wake_up_process(task);}#endif//SDIO_TEST_CASE7#if defined(SDIO_TEST_CASE8)#define TEST_BUF_LEN 8192 //SDIO_TEST_CASE8char *data_test_ptr = NULL;static int gaole_test_count = 0;static struct timeval start_time;static struct timeval stop_time;static signed long long elapsed_time;static int last_chn = 0;bool stop_test = 0;void test_sdio_recv_func(void){	int i;		int read_chn = 0;	int datalen = 0;	//SDIOTRAN_ERR("/nap recv: active_chn is 0x%x!!!/n",active_chn);		if(last_chn != read_chn)	{		last_chn = read_chn;		gaole_test_count = 0;	}	gaole_test_count ++;			//.........这里部分代码省略.........
开发者ID:ShinySide,项目名称:SM-G361H,代码行数:101,


示例17: try_to_freeze_tasks

static int try_to_freeze_tasks(bool sig_only){	struct task_struct *g, *p;	unsigned long end_time;	unsigned int todo;	struct timeval start, end;	u64 elapsed_csecs64;	unsigned int elapsed_csecs;	unsigned int wakeup = 0;	do_gettimeofday(&start);	end_time = jiffies + TIMEOUT;	do {		todo = 0;		read_lock(&tasklist_lock);		do_each_thread(g, p) {			if (frozen(p) || !freezeable(p))				continue;			if (!freeze_task(p, sig_only))				continue;			/*			 * Now that we've done set_freeze_flag, don't			 * perturb a task in TASK_STOPPED or TASK_TRACED.			 * It is "frozen enough".  If the task does wake			 * up, it will immediately call try_to_freeze.			 *			 * Because freeze_task() goes through p's			 * scheduler lock after setting TIF_FREEZE, it's			 * guaranteed that either we see TASK_RUNNING or			 * try_to_stop() after schedule() in ptrace/signal			 * stop sees TIF_FREEZE.			 */			if (!task_is_stopped_or_traced(p) &&			    !freezer_should_skip(p))				todo++;		} while_each_thread(g, p);		read_unlock(&tasklist_lock);		yield();			/* Yield is okay here */		if (todo && has_wake_lock(WAKE_LOCK_SUSPEND)) {			wakeup = 1;			break;		}		if (time_after(jiffies, end_time))			break;	} while (todo);	do_gettimeofday(&end);	elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);	do_div(elapsed_csecs64, NSEC_PER_SEC / 100);	elapsed_csecs = elapsed_csecs64;	if (todo) {		/* This does not unfreeze processes that are already frozen		 * (we have slightly ugly calling convention in that respect,		 * and caller must call thaw_processes() if something fails),		 * but it cleans up leftover PF_FREEZE requests.		 */		printk("/n");		printk(KERN_ERR "Freezing of tasks %s after %d.%02d seconds "				"(%d tasks refusing to freeze):/n",				wakeup ? "aborted" : "failed",				elapsed_csecs / 100, elapsed_csecs % 100, todo);		if(!wakeup)			show_state();		read_lock(&tasklist_lock);		do_each_thread(g, p) {			task_lock(p);			if (freezing(p) && !freezer_should_skip(p) &&							elapsed_csecs > 100)				printk(KERN_ERR " %s/n", p->comm);			cancel_freezing(p);			task_unlock(p);		} while_each_thread(g, p);		read_unlock(&tasklist_lock);	} else {
开发者ID:Jazz-823,项目名称:kernel_ayame,代码行数:78,


示例18: try_to_freeze_tasks

static int try_to_freeze_tasks(bool user_only){	struct task_struct *g, *p;	unsigned long end_time;	unsigned int todo;	bool wq_busy = false;	struct timeval start, end;	u64 elapsed_csecs64;	unsigned int elapsed_csecs;	bool wakeup = false;	do_gettimeofday(&start);	end_time = jiffies + TIMEOUT;	if (!user_only)		freeze_workqueues_begin();	while (true) {		todo = 0;		read_lock(&tasklist_lock);		do_each_thread(g, p) {			if (p == current || !freeze_task(p))				continue;			/*                                                                                                                                                                                                                                                                                                                                                                                                    */			if (!task_is_stopped_or_traced(p) &&			    !freezer_should_skip(p))				todo++;		} while_each_thread(g, p);		read_unlock(&tasklist_lock);		if (!user_only) {			wq_busy = freeze_workqueues_busy();			todo += wq_busy;		}		if (!todo || time_after(jiffies, end_time))			break;		if (pm_wakeup_pending()) {			wakeup = true;			break;		}		/*                                                                                                    */		msleep(10);	}	do_gettimeofday(&end);	elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);	do_div(elapsed_csecs64, NSEC_PER_SEC / 100);	elapsed_csecs = elapsed_csecs64;	if (todo) {		/*                                                                                                                                                                                                                                            */		if(wakeup) {			printk("/n");			printk(KERN_ERR "Freezing of %s aborted/n",					user_only ? "user space " : "tasks ");		}		else {			printk("/n");			printk(KERN_ERR "Freezing of tasks %s after %d.%02d seconds "			       "(%d tasks refusing to freeze, wq_busy=%d):/n",			       wakeup ? "aborted" : "failed",			       elapsed_csecs / 100, elapsed_csecs % 100,			       todo - wq_busy, wq_busy);		}		if (!wakeup) {			read_lock(&tasklist_lock);			do_each_thread(g, p) {				if (p != current && !freezer_should_skip(p)				    && freezing(p) && !frozen(p) &&				    elapsed_csecs > 100)					sched_show_task(p);			} while_each_thread(g, p);			read_unlock(&tasklist_lock);		}	} else {
开发者ID:romanbb,项目名称:android_kernel_lge_d851,代码行数:97,


示例19: try_to_freeze_tasks

static int try_to_freeze_tasks(bool user_only){	struct task_struct *g, *p;	unsigned long end_time;	unsigned int todo;	bool wq_busy = false;	struct timeval start, end;	u64 elapsed_msecs64;	unsigned int elapsed_msecs;	bool wakeup = false;	int sleep_usecs = USEC_PER_MSEC;	char suspend_abort[MAX_SUSPEND_ABORT_LEN];	do_gettimeofday(&start);	end_time = jiffies + msecs_to_jiffies(freeze_timeout_msecs);	if (!user_only)		freeze_workqueues_begin();	while (true) {		todo = 0;		read_lock(&tasklist_lock);		do_each_thread(g, p) {			if (p == current || !freeze_task(p))				continue;			if (!freezer_should_skip(p))				todo++;		} while_each_thread(g, p);		read_unlock(&tasklist_lock);		if (!user_only) {			wq_busy = freeze_workqueues_busy();			todo += wq_busy;		}		if (!todo || time_after(jiffies, end_time))			break;		if (pm_wakeup_pending()) {#ifndef CONFIG_UML			pm_get_active_wakeup_sources(suspend_abort,				MAX_SUSPEND_ABORT_LEN);#endif			log_suspend_abort_reason(suspend_abort);			wakeup = true;			break;		}		/*		 * We need to retry, but first give the freezing tasks some		 * time to enter the refrigerator.  Start with an initial		 * 1 ms sleep followed by exponential backoff until 8 ms.		 */		usleep_range(sleep_usecs / 2, sleep_usecs);		if (sleep_usecs < 8 * USEC_PER_MSEC)			sleep_usecs *= 2;	}	do_gettimeofday(&end);	elapsed_msecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);	do_div(elapsed_msecs64, NSEC_PER_MSEC);	elapsed_msecs = elapsed_msecs64;	if (wakeup) {		printk("/n");		printk(KERN_ERR "Freezing of tasks aborted after %d.%03d seconds",		       elapsed_msecs / 1000, elapsed_msecs % 1000);	} else if (todo) {		printk("/n");		printk(KERN_ERR "Freezing of tasks failed after %d.%03d seconds"		       " (%d tasks refusing to freeze, wq_busy=%d):/n",		       elapsed_msecs / 1000, elapsed_msecs % 1000,		       todo - wq_busy, wq_busy);		read_lock(&tasklist_lock);		do_each_thread(g, p) {			if (p != current && !freezer_should_skip(p)			    && freezing(p) && !frozen(p))				sched_show_task(p);		} while_each_thread(g, p);		read_unlock(&tasklist_lock);	} else {
开发者ID:AICP,项目名称:kernel_moto_shamu,代码行数:84,


示例20: try_to_freeze_tasks

static int try_to_freeze_tasks(bool user_only){	struct task_struct *g, *p;	struct task_struct *t = NULL;	unsigned long end_time;	unsigned int todo;	bool wq_busy = false;	struct timeval start, end;	u64 elapsed_msecs64;	unsigned int elapsed_msecs;	bool wakeup = false;	int sleep_usecs = USEC_PER_MSEC;	do_gettimeofday(&start);	end_time = jiffies + TIMEOUT;	if (!user_only)		freeze_workqueues_begin();	while (true) {		todo = 0;		read_lock(&tasklist_lock);		do_each_thread(g, p) {			if (p == current || !freeze_task(p))				continue;			/*			 * Now that we've done set_freeze_flag, don't			 * perturb a task in TASK_STOPPED or TASK_TRACED.			 * It is "frozen enough".  If the task does wake			 * up, it will immediately call try_to_freeze.			 *			 * Because freeze_task() goes through p's scheduler lock, it's			 * guaranteed that TASK_STOPPED/TRACED -> TASK_RUNNING			 * transition can't race with task state testing here.			 */			if (!task_is_stopped_or_traced(p) &&			    !freezer_should_skip(p)) {				todo++;				t = p;			}		} while_each_thread(g, p);		read_unlock(&tasklist_lock);		if (!user_only) {			wq_busy = freeze_workqueues_busy();			todo += wq_busy;		}        if (!todo || time_after(jiffies, end_time))			break;		if (pm_wakeup_pending()) {			wakeup = true;			break;		}		/*		 * We need to retry, but first give the freezing tasks some		 * time to enter the refrigerator.  Start with an initial		 * 1 ms sleep followed by exponential backoff until 8 ms.		 */		usleep_range(sleep_usecs / 2, sleep_usecs);		if (sleep_usecs < 8 * USEC_PER_MSEC)			sleep_usecs *= 2;	}	do_gettimeofday(&end);	elapsed_msecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);	do_div(elapsed_msecs64, NSEC_PER_MSEC);	elapsed_msecs = elapsed_msecs64;	if (todo) {		printk("/n");		printk(KERN_ERR "Freezing of tasks %s after %d.%03d seconds "		       "(%d tasks refusing to freeze, wq_busy=%d):/n",		       wakeup ? "aborted" : "failed",		       elapsed_msecs / 1000, elapsed_msecs % 1000,		       todo - wq_busy, wq_busy);				if (!wakeup) {			read_lock(&tasklist_lock);			do_each_thread(g, p) {				if (p != current && !freezer_should_skip(p)				    && freezing(p) && !frozen(p))					sched_show_task(p);			} while_each_thread(g, p);			read_unlock(&tasklist_lock);		}	} else {
开发者ID:amadews,项目名称:j608_fly_4511,代码行数:91,



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


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