Skip to content
Advertisement

Tag: pthreads

Design of multi-threaded server in c

When trying to implement a simple echo server with concurrent support on linux. Following approaches are used: Use pthread functions to create a pool of thread, and maintained in a linked list. It’s created on process start, and destroy on process termination. Main thread will accept request, and use a POSIX message queue to store accepted socket file descriptor. Threads

C – pthread_self() getting truncated first 4 bytes?

I’m having trouble getting pthread_equal() to match stored pthreads. The pthread_t I get from pthread_self() seems to be truncated by 4 bytes compared to the one I get from pthread_create(). Comparisons are in the last code block! As a result, an attempt to loop through the stored pthreads and compare with pthread_equals fail. Some comparisons (all ten, every time, get

SEGFAULT after recv from socket

I have next trouble: after receiving data from sockets, server app generates segfault and shutdown. Code of client and server side are below. server: Client: In other words, client connected successfully. But after sending message, server generate segm fault error. What went wrong? Answer When running the code it seg faults at: Package is a struct with two members nick

Does Java JVM use pthread?

Does JVM on Mac OS X use pthread to create threads? What about on Linux distributions, is it now default way to create threads for JVM on all distributions? Answer Yes, HotSpot JVM (i.e. Oracle JDK and OpenJDK) uses pthreads on Linux and on Mac OS X.

pthread_mutex_t in multiple processes…who destroys it?

I’m using a pthread_mutex_t to synchronize access to a resource between multiple processes which are on the same level (i.e. there isn’t a parent/child relationship). How can I determine when it’s safe to call pthread_mutex_destroy? The only way I can think of to determine if the mutex is in use by another process without introducing a race condition is to

Which thread handles the signal?

I have 2 threads(thread1 and thread2). And I have signal disposition for SIGINT. Whenever SIGINT occurs thread 2 should handle the signal. For that I wrote below program I compiled and and run the program. for every 1 second “thread1 active” is printing and for every 3 seconds “thread2 active” is printing. Now I generated SIGINT. But its printing “thread1

Advertisement