I basically want to inform main that a client disconnected in order to decrement the thread counter. Right now my program is setup to only create a certain number of threads to serve the connecting clients. If the client disconnects the thread count needs to be decremented so that it does not max out and not allow further threads to be made for waiting clients.
Now I can use a global variable, but I am doing this to learn more about Unix system programming and I thought either pipes or message queues would be interesting to try out. My problem is I am not sure how my code can utilize this to send information from child thread to main thread.
I wrote some quick and dirty code as an to test out different ways of what I need to do.
In my code I commented where I want to send message back to main process.
I have client code if you do need I can post, but the code below should be sufficient.
Hi all,
I'm trying to write a program that has some data it wants to send through a filter program(in this case tr), and then recieve the output from that filter program. The way I'm trying to do it is by setting up two pipes between the programs and piping the data in through one pipe and back... (2 Replies)
Hi,
I am stuck up with a strange problem.
I am writing an application - a kinda tracker that reads data from memcache and invokes theads to process each record of the memcache.
I dont want to join all my threads because my tracker should poll the cache in regular intervals say sum 300... (2 Replies)
i have a parent process and 5 child process.
As soon as the parent process is completed the 5 child processes need to start simultaneously (like multithreading)
All I need to do in a shell script
the child process is a function
can any one help me on this
thanks in advance (1 Reply)
Hi guys, I'm having some problem here, I'm studying pipes, and i want to create a shell in C and at this point a don't want to use semaphores, instead I want to use tricks. Straight to the doubt: I've a parent and a child process, and both of them has some code to execute, and the child process... (5 Replies)
Parent Thread Of Child Thread
Suppose a process creates some threads say threadC and threadD.
Later on each of these threads create new child threads say threadC1, threadC2, threadC3 etc. So a tree of threads will get created.
Is there any way to find out the parent thread of one such... (1 Reply)
Hi all,
Can I create multiple threads using single thread_id
like
pthread_t thread_id;
pthread_create(&thread_id, NULL, &print_xs, NULL);
pthread_create(&thread_id, NULL, &print_ys, NULL);
pthread_create(&thread_id, NULL, &print_zs, NULL);
pthread_join(thread_id, NULL);
what... (2 Replies)
Hi!
I am writing a C program that will create a child, child will create a thread and the thread will send a message to a unnamed pipe and will print the message before exiting.
here is my work:
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include... (6 Replies)
What is the best way for a parent to kill a child thread that has blocked on a command it cannot finish and will never read another line of its code? Will pthread_cancel() work with a thread that will never stop processing its current line of code? Thanks. (4 Replies)
Hi,
I am trying my hand in networking programming in C, and got stuck in piping.
I was following some tutorial and did the forking like :
while (1)
{
newsockfd = accept(sockfd,
(struct sockaddr *) &cli_addr, &clilen);
if (newsockfd < 0)
... (4 Replies)
I would like to know is there any we can kill a single thread among multiple threads belongs to process?
Since Signal action is process wise not per thread, i strongly feel that we can not or for that mater from external sources as well single thread can not be killed which is critical section... (2 Replies)
Discussion started by: murali242512
2 Replies
LEARN ABOUT MINIX
door_server_create
door_server_create(3DOOR) Door Library Functions door_server_create(3DOOR)NAME
door_server_create - specify an alternative door server thread creation function
SYNOPSIS
cc -mt [ flag ... ] file ... -ldoor [ library ... ]
#include <door.h>
void (*) () door_server_create(void (*create_proc)(door_info_t*));
DESCRIPTION
Normally, the doors library creates new door server threads in response to incoming concurrent door invocations automatically. There is no
pre-defined upper limit on the number of server threads that the system creates in response to incoming invocations (1 server thread for
each active door invocation). These threads are created with the default thread stack size and POSIX (see standards(5)) threads cancella-
tion disabled. The created threads also have the THR_BOUND | THR_DETACHED attributes for Solaris threads and the PTHREAD_SCOPE_SYSTEM
| PTHREAD_CREATE_DETACHED attributes for POSIX threads. The signal disposition, and scheduling class of the newly created thread are
inherited from the calling thread (initially from the thread calling door_create(), and subsequently from the current active door server
thread).
The door_server_create() function allows control over the creation of server threads needed for door invocations. The procedure create_proc
is called every time the available server thread pool is depleted. In the case of private server pools associated with a door (see the
DOOR_PRIVATE attribute in door_create()), information on which pool is depleted is passed to the create function in the form of a
door_info_t structure. The di_proc and di_data members of the door_info_t structure can be used as a door identifier associated with the
depleted pool. The create_proc procedure may limit the number of server threads created and may also create server threads with appropri-
ate attributes
(stack size, thread-specific data, POSIX thread cancellation, signal mask, scheduling attributes, and so forth) for use with door invoca-
tions.
The specified server creation function should create user level threads using thr_create() with the THR_BOUND flag, or in the case of
POSIX threads, pthread_create() with the PTHREAD_SCOPE_SYSTEM attribute. The server threads make themselves available for incoming door
invocations on this process by issuing a door_return(NULL, 0, NULL, 0). In this case, the door_return() arguments are ignored. See
door_return(3DOOR) and thr_create(3C).
The server threads created by default are enabled for POSIX thread cancellations which may lead to unexpected thread terminations while
holding resources (such as locks) if the client aborts the associated door_call(). See door_call(3DOOR). Unless the server code is truly
interested in notifications of client aborts during a door invocation and is prepared to handle such notifications using cancellation
handlers, POSIX thread cancellation should be disabled for server threads using pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL).
The create_proc procedure need not create any additional server threads if there is at least one server thread currently active in the
process (perhaps handling another door invocation) or it may create as many as seen fit each time it is called. If there are no available
server threads during an incoming door invocation, the associated door_call() blocks until a server thread becomes available. The cre-
ate_proc procedure must be MT-Safe.
RETURN VALUES
Upon successful completion, door_server_create() returns a pointer to the previous server creation function. This function has no failure
mode (it cannot fail).
EXAMPLES
Example 1: Creating door server threads.
The following example creates door server threads with cancellation disabled and an 8k stack instead of the default stack size:
#include <door.h>
#include <pthread.h>
#include <thread.h>
void *
my_thread(void *arg)
{
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
door_return(NULL, 0, NULL, 0);
}
void
my_create(door_info_t *dip)
{
thr_create(NULL, 8192, my_thread, NULL,
THR_BOUND | THR_DETACHED, NULL);
}
main()
{
(void)door_server_create(my_create);
...
}
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Architecture |all |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
|Interface Stability |Evolving |
+-----------------------------+-----------------------------+
|MT-Level |Safe |
+-----------------------------+-----------------------------+
SEE ALSO door_bind(3DOOR), door_call(3DOOR), door_create(3DOOR), door_return(3DOOR), libdoor(3LIB), pthread_create(3C), pthread_setcancelstate(3C),
thr_create(3C), attributes(5), cancellation(5), standards(5)SunOS 5.10 20 Aug 1997 door_server_create(3DOOR)