What is the best way to ensure a child package fails if the main data flow in it fails, if it encounters any error ?
I was thinking of the OnTaskFailed Event handler , that has the main data flow (Task 1 ) and an execute sql task ( Task 2) to write to a table that the event has failed. Is it as easy as that or is there anything else that needs to be set up ?
Best done through an event handler on the data flow
I am developing a system where a single parent process creates 10 child processes. The parent process assigns independent tasks to individual child and parent-child communication is done via message queues. Now I need to add one more functionality by which asynchronous timers would run and at a regular interval, timer asks the parent process to ping each child process to check if child is running fine and child replies back. If a child does not reply back thrice after the ping call is made, the parent kills the child and forks another child to assign that task. What would be the best option to add this timer which would trigger IPC between parent and child processes at a regular interval? I was trying to build individual process wise timer with timer_create but could not achieve it.
This is a follow up/modification of my qn : Ptrace/wait on a non child
How do I ptrace or wait on a process that is not a child AND the process that waits is not a root user .
I tried to be in the same group, still doesnt work [ operation not permitted - to ptrace on a non-child ]
ptracing a process gives you complete control over it. If you could ptrace a process belonging to a different user, then users would be meaningless.
wait is specifically for parent notification.
You'll have to rethink your approach to whatever problem you're trying to solve.
Hi guys I would like to know what happens if I am in the middle of a task thats priority is Render and I create another task with priority send. Will Dispatcher will till its done with its tasks of priority render and then my task of highest priority which is send will be executed?
Will Dispatcher will till its done with its tasks of priority render and then my task of highest priority which is send will be executed?
Yes. The priority is only used when the Dispatcher starts each task. It will not stop an operation already in process.
In my program, I use a single thread pool to dispatch all my task, like timer task, non-blocking socket I/O, etc. A task is actually an callback function, which will be executed when specific event received.
The architecture is :
The main thread calls epoll() to harvest the I/O event, then dispatch the I/O callback to the thread pool.
The main thread also handle timer timeout, and dispatch the timeout callback to the thread pool
In an I/O callback, one timer task may be cancelled, depending on I/O processing result.
During one I/O callback is running, the coresponding socket is not monitored for further identical event.
Durning one timer callback is running, that timer task will temporarily removed from the timer task queue.
Here is the problem:
During thread A in the pool is running a timer callback T.
Thread B in the pool may be running another callback(registered for an socket I/O read event), after processing request received, thread B decide to delete the timer task T, but that timer task T is being executed by thread A right now.
I can add an lock for the timer task, but where should I place the lock? I can't place the lock object in the timer task structure, because when I decide to free the task object, I must have already acquired the lock, free and held lock, may lead to undefined behaviours:
pthread_mutex_lock(T->mutex);
free(T);
/*without a pthread_mutex_unlock(T->mutex);*/
And what happened if another thread is blocked on :
pthread_mutex_lock(T->mutex);
Without these problem being addressed, I can't continue my work.Please HELP me out!
Should I use separate thread pool for task of different types in my single process? Or just use single thread?
Any suggestion is appreciated!
You can use a global table of timers protected by its own mutex. The table does not actually need to be global but can belong to some collection, such as whatever owns all the things you are doing I/O on.
Then use this logic:
To create a timer:
Lock the global table.
Add the timer to the global table in state "pending".
Unlock the global table.
Schedule the timer with the thread pool.
To fire a timer:
Lock the global table.
Check the timer's state. If it's not "pending", delete the timer, unlock the table, and stop.
Change the timer's state to "firing".
Unlock the global table.
Perform the timer operation.
Lock the global table.
Remove the timer from the table.
Unlock the global table.
To cancel a timer:
Lock the global table.
Find the timer. If it's state is "pending", change it to "cancelled". Do not delete it.
Unlock the global table.
Can't you refernce count the tasks? When thread A in the pool is running a timer callback T you mark it (e.g. using interlocked increment). When it finishes you decrement the usage. It cannot be freed until the usage is zero.