Loading conf/layer.conf +1 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,6 @@ BBFILE_PRIORITY_meta-oscourse = "8" LAYERVERSION_meta-oscourse = "1" LAYERDEPENDS_meta-oscourse = "core" LAYERSERIES_COMPAT_meta-oscourse = "honister" MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "hello kmalloc-mod vmalloc-mod request-region request-mem-region kthread" MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "hello kmalloc-mod vmalloc-mod request-region request-mem-region kthread kthbindcpu" KERNEL_MODULE_AUTOLOAD += "hello kmalloc-mod vmalloc-mod request-region request-mem-region " recipes-modules/kthbindcpu/files/Makefile 0 → 100644 +13 −0 Original line number Diff line number Diff line obj-m += kthbindcpu.o SRC := $(shell pwd) all: $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install: $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install clean: $(MAKE) -C $(KERNEL_SRC) M=$(SRC) clean recipes-modules/kthbindcpu/files/kthbindcpu.c 0 → 100644 +54 −0 Original line number Diff line number Diff line #include <linux/module.h> #include <linux/kthread.h> #include <linux/sched.h> #include <linux/delay.h> static struct task_struct *thr = NULL; static int demo_thr(void *data) { while(!kthread_should_stop()) { printk(KERN_ALERT"hello kernel thread kthreadtest ,bind cpu %d\n" ,thr->cpu); msleep(9000); } return 0; } static int __init kth_bindCPU_init(void) { int num = 0; printk(KERN_ALERT"Kernel thread start!\n"); thr = kthread_create(demo_thr,NULL,"kth_bindCPU-demo"); if(!thr) { printk(KERN_ERR"kthread_create fail\n"); return -1; } num = num_online_cpus( ); printk(KERN_ALERT"online cpus num %d\n",num); kthread_bind(thr,num-1); wake_up_process(thr); return 0; } static void __exit kth_bindCPU_exit(void) { if(thr) { kthread_stop(thr); thr =NULL; } printk(KERN_ALERT"Kill kernel thread.\n"); } module_init(kth_bindCPU_init); module_exit(kth_bindCPU_exit); MODULE_LICENSE("GPL"); recipes-modules/kthbindcpu/kthbindcpu_0.1.bb 0 → 100644 +14 −0 Original line number Diff line number Diff line LICENSE = "CLOSED" SRC_URI = "file://kthbindcpu.c \ file://Makefile \ " inherit module S = "${WORKDIR}" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. RPROVIDES:${PN} += "kernel-module-kthread" Loading
conf/layer.conf +1 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,6 @@ BBFILE_PRIORITY_meta-oscourse = "8" LAYERVERSION_meta-oscourse = "1" LAYERDEPENDS_meta-oscourse = "core" LAYERSERIES_COMPAT_meta-oscourse = "honister" MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "hello kmalloc-mod vmalloc-mod request-region request-mem-region kthread" MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "hello kmalloc-mod vmalloc-mod request-region request-mem-region kthread kthbindcpu" KERNEL_MODULE_AUTOLOAD += "hello kmalloc-mod vmalloc-mod request-region request-mem-region "
recipes-modules/kthbindcpu/files/Makefile 0 → 100644 +13 −0 Original line number Diff line number Diff line obj-m += kthbindcpu.o SRC := $(shell pwd) all: $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install: $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install clean: $(MAKE) -C $(KERNEL_SRC) M=$(SRC) clean
recipes-modules/kthbindcpu/files/kthbindcpu.c 0 → 100644 +54 −0 Original line number Diff line number Diff line #include <linux/module.h> #include <linux/kthread.h> #include <linux/sched.h> #include <linux/delay.h> static struct task_struct *thr = NULL; static int demo_thr(void *data) { while(!kthread_should_stop()) { printk(KERN_ALERT"hello kernel thread kthreadtest ,bind cpu %d\n" ,thr->cpu); msleep(9000); } return 0; } static int __init kth_bindCPU_init(void) { int num = 0; printk(KERN_ALERT"Kernel thread start!\n"); thr = kthread_create(demo_thr,NULL,"kth_bindCPU-demo"); if(!thr) { printk(KERN_ERR"kthread_create fail\n"); return -1; } num = num_online_cpus( ); printk(KERN_ALERT"online cpus num %d\n",num); kthread_bind(thr,num-1); wake_up_process(thr); return 0; } static void __exit kth_bindCPU_exit(void) { if(thr) { kthread_stop(thr); thr =NULL; } printk(KERN_ALERT"Kill kernel thread.\n"); } module_init(kth_bindCPU_init); module_exit(kth_bindCPU_exit); MODULE_LICENSE("GPL");
recipes-modules/kthbindcpu/kthbindcpu_0.1.bb 0 → 100644 +14 −0 Original line number Diff line number Diff line LICENSE = "CLOSED" SRC_URI = "file://kthbindcpu.c \ file://Makefile \ " inherit module S = "${WORKDIR}" # The inherit of module.bbclass will automatically name module packages with # "kernel-module-" prefix as required by the oe-core build environment. RPROVIDES:${PN} += "kernel-module-kthread"