H
Harsha_MR
Guest
I have multiple processes dependent on signal from one process. If I'm doing the below operation with only 2 processes (A & B), it's faster. But, when I have more and more processes to run in synchronization, its taking too much of time. It's like if a process takes 10msec for processing, when I'm running 5 processes, it takes 50msec. Is it supposed to behave like this..? Its very slow for my requirement.
For Ex:
Process A create events, "Start_process_B" & "Start_process_C"
and Process B wakes up with the event "Start_process_B" from Process A
and Process C wakes up with the event "Start_process_C" from Process A
When Process B and Process C are done, they use SetEvent to signal Process A.
Process B signal Process A with "Donewith_process_B"
Process C signal Process A with "Donewith_process_C"
Process A waits on WaitForMultipleObjects for events from Process B and Process C before its signalling the events to them again.
Code Sample
-------------------------------Process A
static HANDLE aEvent[10],bEvent[10];
aEvent[0] = CreateEvent(NULL, FALSE, FALSE, TEXT("Start_process_B")); // All Events created are Auto Reset Events
aEvent[1] = CreateEvent(NULL, FALSE, FALSE, TEXT("Start_process_C"));
bEvent[0] = OpenEvent(SYNCHRONIZE, FALSE, TEXT("Donewith_process_B"));
bEvent[1] = OpenEvent(SYNCHRONIZE, FALSE, TEXT("Donewith_process_c"));
while(1)
{
for (int k = 0; k < 2; k++)
{
SetEvent(aEvent[k]);
}
WaitForMultipleObjects(2, bEvent, TRUE, INFINITE);
}
-------------------------------Process B
static HANDLE aEvent, bEvent;
aEvent = OpenEvent(SYNCHRONIZE, FALSE, TEXT("Start_process_B"));
bEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("Donewith_process_B"));
while(1)
{
WaitForSingleObject(bEvent, INFINITE);
......do some processing here
SetEvent(bEvent); //Signal Process A of completion
}
-------------------------------Process C
static HANDLE aEvent, cEvent;
aEvent = OpenEvent(SYNCHRONIZE, FALSE, TEXT("Start_process_c"));
cEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("Donewith_process_c"));
while(1)
{
WaitForSingleObject(cEvent, INFINITE);
......do some processing here
SetEvent(cEvent); //Signal Process A of completion
}
System configuration
Intel Xeon E5 2660 server v4 2.0Ghz (2 processor) with Windows 10 OS(64 Bit)
Continue reading...
For Ex:
Process A create events, "Start_process_B" & "Start_process_C"
and Process B wakes up with the event "Start_process_B" from Process A
and Process C wakes up with the event "Start_process_C" from Process A
When Process B and Process C are done, they use SetEvent to signal Process A.
Process B signal Process A with "Donewith_process_B"
Process C signal Process A with "Donewith_process_C"
Process A waits on WaitForMultipleObjects for events from Process B and Process C before its signalling the events to them again.
Code Sample
-------------------------------Process A
static HANDLE aEvent[10],bEvent[10];
aEvent[0] = CreateEvent(NULL, FALSE, FALSE, TEXT("Start_process_B")); // All Events created are Auto Reset Events
aEvent[1] = CreateEvent(NULL, FALSE, FALSE, TEXT("Start_process_C"));
bEvent[0] = OpenEvent(SYNCHRONIZE, FALSE, TEXT("Donewith_process_B"));
bEvent[1] = OpenEvent(SYNCHRONIZE, FALSE, TEXT("Donewith_process_c"));
while(1)
{
for (int k = 0; k < 2; k++)
{
SetEvent(aEvent[k]);
}
WaitForMultipleObjects(2, bEvent, TRUE, INFINITE);
}
-------------------------------Process B
static HANDLE aEvent, bEvent;
aEvent = OpenEvent(SYNCHRONIZE, FALSE, TEXT("Start_process_B"));
bEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("Donewith_process_B"));
while(1)
{
WaitForSingleObject(bEvent, INFINITE);
......do some processing here
SetEvent(bEvent); //Signal Process A of completion
}
-------------------------------Process C
static HANDLE aEvent, cEvent;
aEvent = OpenEvent(SYNCHRONIZE, FALSE, TEXT("Start_process_c"));
cEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("Donewith_process_c"));
while(1)
{
WaitForSingleObject(cEvent, INFINITE);
......do some processing here
SetEvent(cEvent); //Signal Process A of completion
}
System configuration
Intel Xeon E5 2660 server v4 2.0Ghz (2 processor) with Windows 10 OS(64 Bit)
Continue reading...