A
Aggelidis Nikos
hi to all,
i have a question concerning threads and vlas.
It is a know fact that pthreads share the same address space. I thought
that this meant that whatever variable i had in main() before creating
a thread, i would be able to use in the thread-itself. Unfortunately
threads have different stacks and that means that any local variable of
main can't be used by threads.
So in order for a variable to be used inside a thread, i see 2 options.
1) pass the variable as an argument to the thread
2) have a global variable that anyone can modify
The problems begin when i decided that i wanted to use a c99 feature:
the variable length arrays {vla}. The problem is that i can't declare a
gloval vla {it isn't permitted by the language}. Also i can't have a vla
inside a structure.... so what can i do?
I don't know if the context of my problem is relevant but for what is worth:
i want to have a 2d vla and i want to be able to "alter" it through threads...
thanks for your time,
nicolas
i have a question concerning threads and vlas.
It is a know fact that pthreads share the same address space. I thought
that this meant that whatever variable i had in main() before creating
a thread, i would be able to use in the thread-itself. Unfortunately
threads have different stacks and that means that any local variable of
main can't be used by threads.
So in order for a variable to be used inside a thread, i see 2 options.
1) pass the variable as an argument to the thread
2) have a global variable that anyone can modify
The problems begin when i decided that i wanted to use a c99 feature:
the variable length arrays {vla}. The problem is that i can't declare a
gloval vla {it isn't permitted by the language}. Also i can't have a vla
inside a structure.... so what can i do?
I don't know if the context of my problem is relevant but for what is worth:
i want to have a 2d vla and i want to be able to "alter" it through threads...
thanks for your time,
nicolas