Guidosoft
March 21st, 2006, 11:32 AM
I just recently learned about this interpocess counter called a semaphore and it got me to wondering. Perhaps you could use this to send messages to windowless processes.
Think about it. You have 2 semaphores.
1. The pulse semaphore.
2. The flag semaphore.
Now the flag semaphore is set to 0. Its max is 1.
The pulse sephamore is set to 0 and has a max of 256.
1 is 0, 2 is 1, so on.
Now, when the flag sephamore is set to 1(which you know by WaitForObject), you release the pulse sephamore to the byte number you want.
Then the one that is reading the data, will keep Waiting for the pulse object until it gets WAIT_TIMEOUT. It loops however many it recieved and counts. The count -1 is the byte number.
It writes this to a buffer, then relealses flag sephamore and repeats the process. This is how it recieves bytes.
With a few extra imhancements you can devise a fully fledged interprocess communication system.
What do you guys think of this idea? Do you think it is possible to do it in this way?
Think about it. You have 2 semaphores.
1. The pulse semaphore.
2. The flag semaphore.
Now the flag semaphore is set to 0. Its max is 1.
The pulse sephamore is set to 0 and has a max of 256.
1 is 0, 2 is 1, so on.
Now, when the flag sephamore is set to 1(which you know by WaitForObject), you release the pulse sephamore to the byte number you want.
Then the one that is reading the data, will keep Waiting for the pulse object until it gets WAIT_TIMEOUT. It loops however many it recieved and counts. The count -1 is the byte number.
It writes this to a buffer, then relealses flag sephamore and repeats the process. This is how it recieves bytes.
With a few extra imhancements you can devise a fully fledged interprocess communication system.
What do you guys think of this idea? Do you think it is possible to do it in this way?