⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tasklet.c

📁 fsmlabs的real time linux的内核
💻 C
字号:
#include <rtl.h>#include <time.h>#include <linux/interrupt.h> /* for the tasklet macros/functions */#include <pthread.h>int myint_for_something=1;pthread_t thread;void tasklet_function(unsigned long);char tasklet_data[64];DECLARE_TASKLET(test_tasklet,tasklet_function, (unsigned long) &tasklet_data);	void * start_routine(void *arg){	struct sched_param p;	int i;	p . sched_priority = 1;	pthread_setschedparam (pthread_self(), SCHED_FIFO, &p);	pthread_make_periodic_np (pthread_self(), gethrtime(), 500000000);	i=0;	while (1) {		pthread_wait_np ();		rtl_printf("RT-Thread; my arg is %x\n", (unsigned) arg);		sprintf(tasklet_data,"%s \"%x\"",			"Linux tasklet received RT-Thread arg",			(unsigned) arg);		tasklet_hi_schedule(&test_tasklet);		i++;	}	return 0;}	void tasklet_function(unsigned long data){	struct timeval now;	do_gettimeofday(&now);	printk("%s at %ld,%ld\n",(char *) data,now.tv_sec,now.tv_usec);}	int init_module(void) {	return pthread_create (&thread, NULL, start_routine, 0);}void cleanup_module(void) {	pthread_delete_np(thread);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -