473,396 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

message queue and signal notifiers

Hi,

I am trying to implement a blocked or synchronous method of message passing using signal interrupts. So far I have the following:

server.c
{
msgget(queue)
msgrcv (queue mtype)

while(data to send) {
msgsnd(data)
kill(client, SIGUSR1)
}

close queue
}

client.c
{
sigaction(catch SIGUSR1)
msgget(queue)
msgsnd(queue mtype)

while(data to read) {
pause()
printf(dadta)
}
}

The way I can think of doing this is using sa_handler to call a function that reads from the queue when the signal is received. I feel like this isn't the best way to do it since I would have to globally define the structure that gets the data, along with the message queue id returned from msgget too.

I am trying to learn how to use signals better and I would like some pointers on how to do this, or ideas that I can try.

Thanks
May 22 '08 #1
1 3227
gpraghuram
1,275 Expert 1GB
Hi,

I am trying to implement a blocked or synchronous method of message passing using signal interrupts. So far I have the following:

server.c
{
msgget(queue)
msgrcv (queue mtype)

while(data to send) {
msgsnd(data)
kill(client, SIGUSR1)
}

close queue
}

client.c
{
sigaction(catch SIGUSR1)
msgget(queue)
msgsnd(queue mtype)

while(data to read) {
pause()
printf(dadta)
}
}

The way I can think of doing this is using sa_handler to call a function that reads from the queue when the signal is received. I feel like this isn't the best way to do it since I would have to globally define the structure that gets the data, along with the message queue id returned from msgget too.

I am trying to learn how to use signals better and I would like some pointers on how to do this, or ideas that I can try.

Thanks
I would use semaphore or a mutex to accompilish this instead of a signal.
Your idea is good but You will have better control when u use the one which i specified.

Raghuram
May 23 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: Paul L. Du Bois | last post by:
Has anyone written a Queue.Queue replacement that avoids busy-waiting? It doesn't matter if it uses os-specific APIs (eg WaitForMultipleObjects). I did some googling around and haven't found...
0
by: dsclements | last post by:
>Description: I'm running mysql in a 3 server configuration, with 2 servers being slaves to the first. I'm running vpopmail, which means a connection every incoming mail and every check. I woke up...
8
by: Brian Keating EI9FXB | last post by:
Would I be correct in saying that the only way to get a user message into a Windows form would be to use P/Invoke with Message? Of is there some part of the .NET API that I am totally un aware...
4
by: Just D. | last post by:
Did anybody use this Message Queuing and knew all details about it? What's the physical limit of this Message Queuing system, number of messages, mbytes, message size? Where it stores messages,...
0
by: Wavemaker | last post by:
One of the things I've struggled with from time to time is handling events raised on different threads. For example, an object could be listening to events from one or more objects running in...
0
by: Mike | last post by:
Ok, I think I have an understanding of how to (or not to) implement a thread safe message queue. There are several key elements, I will try to be brief without too much code. * Use the dotnet...
8
by: Dave | last post by:
I am trying to write an event-driven application with no main window that runs "forever". It waits on a named event and then displays a window depending on data pased in a memory-mapped file. I...
3
by: hg | last post by:
Hi, Is it legal to use Queue.put in a signal handle and Queue.get in the main process (no thread) Thanks, hg
13
by: Alexandru Mosoi | last post by:
how is Queue intended to be used? I found the following code in python manual, but I don't understand how to stop consumers after all items have been produced. I tried different approaches but all...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.