|
godspeed123 wrote: is there any way that I can do this
of course, you lock the shared resource (here, your circular queue") so that only one can use it at a time (either producer, or Consumer, but not both), and release it then.
you should document yourself about semaphore, mutex, and such security locking systems...
|
|
|
|
|
Thanks for the repsonse.
By doing the locking, wont you lose data? Since the producer wont be able to write the data in at the time that it is available?
|
|
|
|
|
godspeed123 wrote: By doing the locking, wont you lose data?
thanksfully not !
actually, the producer (if it's the producer who wants to use the resource when it's locked) "hibernates" for a certain period, until the comsumer releases the resource.
the problem is if you don't release a locked resource... you can come into an infinite loop...
|
|
|
|
|
So right now what is happeneing is I have a hardware board hooked up to the computer and it throws out data 200 times a second. In the callback of the acquisition board I take the data and copy it into the circular queue. Now the consumer consumes the data at a slower rate, my estimate is 100 times a second, so because it is consuming the data at a slower rate, there will be a time where the producer will overlap the consumer in the circular queue. When this happens and there is a semaphore on it, the data will then be locked and hence I would lose the new data coming in from the acquisition board, would I? Or am I compeltely misunderstanding this
Thanks again
|
|
|
|
|
what you MUST implement however is a security which will forbid the producer to write in the queue if it's already full... it must wait for a consumer goes by there
|
|
|
|
|
godspeed123 wrote: Now the way that it is going now I have this circular queue
Why a circular queue, and not a queue? Maybe even MSMQ[^]?
|
|
|
|
|
With a queue I thought I would over run the memory, and then cause the whole computer to crash.
|
|
|
|
|
godspeed123 wrote: With a queue I thought I would over run the memory, and then cause the whole computer to crash.
The queue does not need to store items (entirely) in the memory. Again, look at MSMQ - it stores messages in files in the MSMQ\Storage folder.
|
|
|
|
|
You may also do this,
Use queue(STL,maybe) and mark the zone you push data into the queue [queue::push(msg)] using Critical section. That works, simple.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Hi,
I'm writing a MFC application with callback dll functions, but it's have the problem with the callback function and mfc. I have two callback functions: OnInviteResult and OnLoginResult are called by a function in a dll. The first function OnLoginResult works fine, but OnInviteResult make the program halt when it execute the line:
pdlg->m_status.ReplaceSel("Connected\r\n");
I have debuged and seen pdlg pointer has the same address in both OnLoginResult and OnInviteResult functions.
Below is my code:
TestDLLDlg.cpp
CTestDLLDlg* pdlg;
.....
CTestDLLDlg::CTestDLLDlg(CWnd* pParent )
: CDialog(CTestDLLDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
pdlg = this;
}
......
void CALLBACK OnLoginResult(int *registered)
{
switch (*registered){
case 1:
pdlg->m_status.ReplaceSel("Registered\r\n");
break;
case 2:
pdlg->m_status.ReplaceSel("Invalid Username or Password\r\n");
break;
case 3:
pdlg->m_status.ReplaceSel("Service Unavaiable\r\n");
break;
}
}
void CALLBACK OnInviteResult(int *status)
{
switch (*status){
case 1:
pdlg->m_status.ReplaceSel("Ringing...\r\n");
break;
case 2:
pdlg->m_status.ReplaceSel("Connected\r\n");
break;
case 3:
pdlg->m_status.ReplaceSel("Hung up\r\n");
break;
default:
break;
}
}
int CTestDLLDlg::SetCallbackFunctions(void)
{
SetCallbackLogin(OnLoginResult);
SetCallbackInvite(OnInviteResult);
return 0;
}
Do you have any idea about this problem?
Any help would be appreciated.
DBQ.
-- modified at 17:31 Wednesday 21st March, 2007
|
|
|
|
|
Van Ly Doc Hanh wrote: but OnInviteResult make the program halt when it execute the line:
pdlg->m_status.ReplaceSel("Connected\r\n");
Which doesn't tell us a whole lot. Have you set a breakpoint on that statement and debugged into it?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I did set the break point on that statement and when I press F10 for that line, it run for a long time and my app become "Not Responding".
DBQ.
|
|
|
|
|
Van Ly Doc Hanh wrote: ...when I press F10 for that line...
I said step into, not over.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'm sorry. I misunderstood your words.
When I hit F11, it pop up a windows:
"Finding source: afxwin2.inl"
f:\vs70builds\3077\vc\mfcatl\ship\atlmfc\include\afxwin2.inl
I tried to step into and it looks like:
Dialog changes the text in CEdit control and send message to Window but there is no control takes that message -> program waiting forever.
How can I solve this problem?
DBQ.
-- modified at 17:27 Wednesday 21st March, 2007
|
|
|
|
|
Press "Shift" + F11 rather than F11.
Press: 1500 to 2,200 messages in just 6 days? How's that possible sir?
Dr.Brad :Well,I just replied to everything Graus did and then argued with Negus for a bit.
|
|
|
|
|
Van Ly Doc Hanh wrote: I did set the break point on that statement and when I press F10 for that line, it run for a long time and my app become "Not Responding".
Use F11 for step into and check the behavior
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
Hello together,
I need some help for my dialog box.
I search an entry for my message map of one dialog box. This entry shall call a function if the dialog box is completly shown on the screen.
The most entries like ON_WM_CREATE or ON_WM_ACTIVATE are called the functions before the dialog box is completely shown on the screen.
Kind regards
GruenerSchreibtisch
|
|
|
|
|
See here.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I am trying to allow a cold fusion app to use a dll. I do not know cold fusion but they say that they use a tag to grab the dll and send it a parameter. It does not call an API function in the dll but rather calls the dll with a parameter. If i create a win 32 dll , can i just put my code in here:
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
Oh maybe not cause this returns bool.
I think it has to be a dll with a "main" section. Any input?
|
|
|
|
|
Hi friends,
I'm trying to forward a TCP/IP port (can be described dynamic) to MySQL port (3306).
Although i've written an MFC project using CASyncSocket to solve this problem. It works with Client/Server text communication based programs but it cannot fwd MySQL requests.
-Let me tell what i did:
1.Listen a port
2.Accept incoming connection (this is the incoming socket)
(for this accepted socket)
I.If receive any data Read max 100 byte packet
II. Add this packet to an array (vector)
III. A thread (consumer thread) checks this array's size
-if there's any packet sends it to 3306 by another CAsyncSocket
object (this is the outgoing socket)
IV. Same process for incoming data from 3306 to accepted socket
i wrote another Client/Server application which only acceps incoming requests and read their messages and echo it to themselves. This is a text based communication.
Result:
forwarder can't forward the data between app and MySQL host
i think main goal is binary data!
how can i do this
Could anyone help me?
Thanks lot,
|
|
|
|
|
I'm lost. Which part isn't working?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
-in project: every time i Receive static sized byte array from incoming socket
then send it to server (with the length of received size)
it only works with text based communication like chat
but mysql send binary data (and uses its' own protocol)
may be..., could you tell about the logical analyse or steps (like overflow diagram) about how to forward an incoming TCP/IP connection to another host:Port
like Proxy's but independent from connection protocol (like physical bridges used to separate sub networks)
thanx a lot for your reply
Note: i must go out coz it's late
|
|
|
|
|
What about data coming FROM the server to the client? Are you relaying all that data too?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Yes, i do reply, when i receive any message from one of them i put it into related queue then forward it
i don't know much about MySQL server communication protocol may it be related with this?
i only want to send all packages from one gate to another gate (and reverse) that's all
|
|
|
|
|
I see you've closed the project but if you were looking at "messages" as they passed through
then you'd need to know everything about the message protocol. Otherwise every byte should
be passed through untouched.
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|