Questions tagged [pthread-exit]

The pthread_exit() function terminates the calling thread and returns a value via retval that (if the thread is joinable) is available to another thread in the same process that calls pthread_join.

The pthread_exit() function terminates the calling thread and returns a value via retval that (if the thread is joinable) is available to another thread in the same process that calls pthread_join.

http://man7.org/linux/man-pages/man3/pthread_exit.3.html

29 questions
0
votes
1 answer

pthread_exit() throws warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] warning

I have been learning about pthread library, and have created a simple code to multiply two numbers, however I'm not able to get rid of this warning. Ps. The code works fine. #include #include struct numbers { int…
Shreyas Shrawage
  • 340
  • 2
  • 10
0
votes
1 answer

Incorrect local variable value after pthread_join

I am trying to sum up 1000 elements integer array(where each element is 1) with pthread library by splitting the array in to segments of size 10. So effectively, 100 threads are being used to do that. The results of this parallel operation is as…
Vineel
  • 1,430
  • 14
  • 18
0
votes
0 answers

Passing address of an integer variable to pthread_exit

The pthread_exit function should take a void pointer as input. I'm wondering how come it's possible to pass the address of an integer variable (e.g. pthread_exit(&ret1) here) without performing a cast conversion.
Gennaro Arguzzi
  • 769
  • 1
  • 14
  • 27
0
votes
1 answer

Exit thread with return

I have a small problem, and I hope finding someone who can help. I am trying to develop a thread library in c using ucontext, and i have developped the basic functions for that. so now my problem is that I want to consider the case when the user…
Ahmed
  • 15
  • 5
0
votes
1 answer

How to convert * to double/float with pthread, pthread_exit

I need to create a program which calculates recursion (for certain sequence). When I use int and decleare a recursion, that calculates values without floating numbers (like fibonacci sequence, which returns only neutral numbers) it works. However,…
Michał
  • 43
  • 1
  • 7
0
votes
1 answer

Trying to understand how pthread works in C

I am trying to use pthread in C to compare two strings. The idea is to see if the complete string 2 is in string 1 (For Example, if string1 = lkajdsgl and string2 = jd then I would have one match). What I don't understand is how the pthread works in…
Joseph
  • 301
  • 3
  • 13
0
votes
1 answer

Why does pthread_exit(0) hangs the program?

Running the following C code causes the program to hang, and does not respond to signals (including CTRL-C). int main() { pthread_exit(0); return 0; } Any idea why? The behaviour is normal when other threads have been created and are…
ralux
  • 25
  • 5
0
votes
1 answer

Posix pthread worker that is only running when needed

I have a worker thread doing a polling activity (it's targeting libcurl but that is not relevant). Many actions from the application can start a worker thread but if it is already running, no new thread should be created. A new request from the…
user1816142
  • 1,199
  • 2
  • 9
  • 16
0
votes
1 answer

Client hangs after pthread_exit() in server thread in C

I have a server where I handle multiple clients. Each client that connects to it is serviced in its own thread. Now, if any errors occur on the server side, I want to exit that thread by calling pthread_exit, and terminate the client that was being…
coder4lyf
  • 927
  • 1
  • 17
  • 36
0
votes
2 answers

Why pthread_exit acts like pthread_join?

Code: void *PrintHello(void *threadid) { cout<<"Hello"<
Sreeraj Chundayil
  • 5,548
  • 3
  • 29
  • 68
0
votes
1 answer

will pthread_exit() closes the opened files too?

i have opened a file in the thread and terminated the thread using pthread_exit() routine. Will it closes the opened files too?
IPS
  • 81
  • 1
  • 12
0
votes
2 answers

Detached thread won't exit although it runs pthread_exit?

I have been dealing with a problem in a thread pool for some days now. I tried all types of different things but I can't seem to solve the issue. I have made a simple version that reproduces the problem. Code: #include #include…
Pithikos
  • 18,827
  • 15
  • 113
  • 136
-1
votes
1 answer

How to prevent memory leaks in pthreads?

How to prevent memory leaks in pthread? I am running a server client program where server has to execute a pthread program and pss the result to client. The client keeps asking for the command again and again until it is stopped. The result provided…
-1
votes
1 answer

Properties of pthread_exit function : which one is right?

In the CSAPP book Section 12.3, They said.. The thread terminates explicitly by calling the pthread_exit function. If the main thread calls pthread_exit, it waits for all other peer threads to terminate and then terminates main thread and the…
alsrbok
  • 15
  • 6
1
2