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

📄 larg_stack.c

📁 fsmlabs的real time linux的内核
💻 C
字号:
#include <rtl.h>#include <time.h>#include <pthread.h>#include <linux/slab.h> /* kmalloc */pthread_t thread;#define SIZE 10000 /* large ugly array */void * start_routine(void *arg){	struct sched_param p;	unsigned long larg_array[SIZE]; /* the large aray */	int i;	p . sched_priority = 1;	pthread_setschedparam (pthread_self(), SCHED_FIFO, &p);	pthread_make_periodic_np (pthread_self(), gethrtime(), 500000000);	/* fill up the large array */	for(i=0;i<SIZE;i++){		larg_array[i]=(unsigned long)i;	}	i=0;	while (i<SIZE){		pthread_wait_np ();		rtl_printf("I'm here %lx\n",larg_array[i++]);	}	return (void *)0;}int init_module(void) {	pthread_attr_t attr;	pthread_attr_init(&attr);	/* default stack size + large data block... */	attr.stack_size = attr.stack_size + (SIZE*sizeof(unsigned long)); 	attr.stack_addr = (int *)kmalloc(attr.stack_size,GFP_KERNEL);	if(!attr.stack_addr){		printk("failed to allocate stack\n");		return -1;	}	return pthread_create(&thread,&attr,start_routine, (void *)0);}void cleanup_module(void) {	void * retval;	pthread_delete_np (thread);	pthread_join(thread,&retval);	printk("thread terminated with %d\n",(int)retval);}

⌨️ 快捷键说明

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