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 OSF1
sem_wait
sem_wait(3) Library Functions Manual sem_wait(3)NAME
sem_wait, sem_trywait - Performs (or conditionally performs) a semaphore lock (P1003.1b)
LIBRARY
Realtime Library (librt.so, librt.a)
SYNOPSIS
#include <semaphore.h>
int sem_wait (
sem_t *sem);
int sem_trywait (
sem_t *sem);
PARAMETERS
sem Specifies a pointer to the semaphore to be locked.
DESCRIPTION
The sem_wait function locks the semaphore referenced by sem by performing a semaphore lock operation on it. If the semaphore value is zero,
the sem_wait function blocks until it either locks the semaphore or is interrupted by a signal.
The sem_trywait function locks a semaphore only if the semaphore is currently not locked. If the semaphore value is zero, the sem_trywait
function returns without locking the semaphore.
These functions help ensure that the resource associated with the semaphore cannot be accessed by other processes. The semaphore remains
locked until the process unlocks it with a call to the sem_post function.
Use the sem_wait function instead of the sem_trywait function if the process should wait for access to the semaphore.
RETURN VALUES
If the sem_wait or sem_trywait function returns successfully, a value of 0 (zero) is returned and the function executes the semaphore lock
operation.
On an unsuccessful call, a value of -1 is returned and errno is set to indicate that an error occurred. The state of the semaphore remains
unchanged.
ERRORS
The sem_wait and sem_trywait functions fail under the following conditions:
[EAGAIN] The semaphore was already locked and cannot be locked by the sem_trywait operation (sem_trywait only).
[EINTR] A signal interrupted this function.
[EINVAL] The sem argument does not refer to a valid semaphore.
RELATED INFORMATION
Functions: sem_post(3)
Guide to Realtime Programming delim off
sem_wait(3)