?? larg_stack.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 + -