# Passing socket struct between kernel threads - module programming

**URL:** <https://community.unix.com/t/passing-socket-struct-between-kernel-threads-module-programming/231427>\
**Category:** UNIX for Advanced & Expert Users\
**Created:** [February 12, 2009, 5:45pm UTC](https://community.unix.com/t/passing-socket-struct-between-kernel-threads-module-programming/231427 "2009-02-12T17:45:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcintom](https://community.unix.com/user_avatar/community.unix.com/marcintom/32/767_2.png) [@marcintom](https://community.unix.com/u/marcintom)\
**Post date:** [February 12, 2009, 5:45pm UTC](https://community.unix.com/t/passing-socket-struct-between-kernel-threads-module-programming/231427/1 "2009-02-12T17:45:37Z")

</div>

I write kernel module with kernel threads using  
linux/kthread.h on 2.6.\* kernel

I tried to passing data between two kernel threads  
with data argument of kthread\_run( fun, data , NAME );  
but this is not work I dont know why. I tried many possibility  
and nothing works.

So I thought that maybe something like this will work  
but not.

```nohighlight
typedef struct my {
    struct socket *tmp;
    struct task_struct *task;
    int (*fun)(void * );
} table[10];
/* this is global static table */

int kthread_fun1(void *d) {
    sock_create( ...., &(tab[0].tmp) )
    printk(" %p ", tab[0].tmp ) <- THIS IS NOT NULL OK
}

int ktrhead_fun2( void *d ) {
    tab[0].tmp <- THIS IS NULL IN THIS CASE WHY

}

init_function_of_module {
    kthread_run( ..., fun1, ... )
 
    kthread_run( ..., fun2, ... )
}

```

Iam sure that fun1 thread was executed before fun2, I used semaphores ( actually completion mechanism ).
