Transmitting the parameter to SystemThread

11 views
Skip to first unread message

hitti...@gmail.com

unread,
Feb 25, 2017, 3:32:02 AM2/25/17
to ns-3-users
In linux, we can write the code like this: 

void *pthread(void *args)
{
    int i = *((int*)args);

    printf("%d\n", i);
}


int main(int argc, char *argv[])
{
    ....
    int num = 3;
    pthread_t id;

    ret = pthread_create(&id, NULL, pthread, (void*)&num);
}


So we can transmit the parameter num to the thread function. 


However, I have no idea how to transmit the parameter to SystemThread. I hope that someone can give me a solution. Thanks! 


Tim Lee
Feb. 26th, 2017

pdbarnes

unread,
Feb 25, 2017, 10:57:47 AM2/25/17
to ns-3-users
SystemThread takes a Callback as the function to execute in the new thread. Have you tried using a BoundCallback to pass the arguments?
https://www.nsnam.org/doxygen/group__makeboundcallback.html

Peter

Reply all
Reply to author
Forward
0 new messages