Click here to Skip to main content
15,913,115 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionplugin development for pocket WMP Pin
Mohammad A Gdeisat28-Jul-06 7:47
Mohammad A Gdeisat28-Jul-06 7:47 
QuestionMemory allocation problem?? Pin
pavanbabut28-Jul-06 7:30
pavanbabut28-Jul-06 7:30 
AnswerRe: Memory allocation problem?? Pin
Zac Howland28-Jul-06 7:51
Zac Howland28-Jul-06 7:51 
GeneralRe: Memory allocation problem?? Pin
pavanbabut28-Jul-06 8:51
pavanbabut28-Jul-06 8:51 
GeneralRe: Memory allocation problem?? Pin
Zac Howland28-Jul-06 9:16
Zac Howland28-Jul-06 9:16 
GeneralRe: Memory allocation problem?? Pin
pavanbabut28-Jul-06 9:32
pavanbabut28-Jul-06 9:32 
GeneralRe: Memory allocation problem?? Pin
Zac Howland28-Jul-06 9:46
Zac Howland28-Jul-06 9:46 
GeneralRe: Memory allocation problem?? Pin
pavanbabut1-Aug-06 5:32
pavanbabut1-Aug-06 5:32 
Hi,
I tried both ways, but still either I am not able to keep up with the read speed or the porgram hangs by taking up 100% of processor. Here are the 2 ways I tried for-
Method1-
1) Created 5 different same size buffers for each of the 3 channels (so 3x5 = 15 different buffers) where the buffers for channel one are of size 100000*6bytes each and that of channels 2&3 are of 100000*1byte each.
2) Created 15 threads to process each of those 15 buffers whenever they are ready (initiated by the main acquisition thread as soon as a buffer becomes ready).
3) Created different binary files to write the corresponding buffer data (to overcome the file access issue).
-In this case the program hangs as soon as I run it and locks the processor at 100% (I think its due to the pool of threads ruuning at the same time).
Method2-
1) Created only 3 threads (for each channel data) to write any of the 5 buffers (allocated in the same fashion as before) depending upon their corresponding buffer flags (again initiated by the main acquisition thread, same as before).
2) Created only 3 files to write the data into (since at any given point of time, only 1 buffer is being accessed by the corresponding threads).
-In this case too, my porcessor is being locked up for a while and at some point the data acquisition board gives out buffer overrun error.

Here is a sample of how I am writing my thread-
DWORD WINAPI StartAThread0(LPVOID param)
{
wwrite_ASignal0(); //for buffer[0] of channel1
return 0;
}

void write_ASignal0()
{
int i, dataA, dataA1 = -8191;
do
{
if (m_bUpdateA[0])
{
for (i=0; i<100000; i++)
{
if (dataAI[0][i] < 0)
fwrite(&dataA1, sizeof(int), 1, streamA[0] ;
else
{
dataA = (int)((dataAI[i][0]-1.25)*6552.8);
fwrite(&dataA, sizeof(int), 1, streamA[0] ); }
}
m_bUpdateA[0] = false;
}
}while(m_bInitialize);
}

Where m_bInitialize keeps the thread running waiting for m_bUpdate[0] to activate. As soon as it does it writes the buffer to the corresponding file and deactivates the flag. In the sam fashion I am having for all the other 14 threads.

Here is my application to be exact-
The board is a Nation Instruments Data Acquisition board which can acquire data at a max of 10MHz. The data is acquired using their own native commands in C. The minimum buffer size I can use to acquire data is 10000 and then 100000. Any number other than these will give out buffer overrun error. So if I use 100000 samples, it means that the board acquires data at 10000000 samples per sec in small chucnks of 100000samples/channel, while syncronizing b/n the board memory and the memory allocated by us. At last the baord acquires 100 chucnks of these data packets to finish off 10MSamples/channel. So, in 1000msec it is acquiring 100 sets of 100000data samples/channel = 10msec/set/channel. When I test my present program for the time it takes to write 100000samples of data on to HDD it shows 14-16msec (so I am having a lag of atleast 4msec, which does have a large effect I think).

This is my observation till now. Plz. do lemme know if you come up with a different idea for implementing this thing.

thanks,
-Pavan
GeneralRe: Memory allocation problem?? Pin
Blake Miller1-Aug-06 12:44
Blake Miller1-Aug-06 12:44 
GeneralRe: Memory allocation problem?? Pin
pavanbabut2-Aug-06 9:40
pavanbabut2-Aug-06 9:40 
GeneralRe: Memory allocation problem?? Pin
Blake Miller2-Aug-06 10:29
Blake Miller2-Aug-06 10:29 
GeneralRe: Memory allocation problem?? Pin
pavanbabut2-Aug-06 13:48
pavanbabut2-Aug-06 13:48 
Questionnewbie requires guidance on named pipe application Pin
eeyor66628-Jul-06 6:31
eeyor66628-Jul-06 6:31 
QuestionHow to set a JPG image to a dialog background ? Pin
Vinod Sankaranarayanan28-Jul-06 6:25
Vinod Sankaranarayanan28-Jul-06 6:25 
AnswerRe: How to set a JPG image to a dialog background ? Pin
Hamid_RT28-Jul-06 6:57
Hamid_RT28-Jul-06 6:57 
GeneralRe: How to set a JPG image to a dialog background ? Pin
Vinod Sankaranarayanan28-Jul-06 19:21
Vinod Sankaranarayanan28-Jul-06 19:21 
GeneralRe: How to set a JPG image to a dialog background ? Pin
Hamid_RT28-Jul-06 21:55
Hamid_RT28-Jul-06 21:55 
Questiontootip for win32 window Pin
Manjunath S28-Jul-06 6:17
Manjunath S28-Jul-06 6:17 
AnswerRe: tootip for win32 window Pin
David Crow28-Jul-06 7:18
David Crow28-Jul-06 7:18 
AnswerRe: tootip for win32 window Pin
Hamid_RT28-Jul-06 7:20
Hamid_RT28-Jul-06 7:20 
QuestionHow to read/write a word from/to a certain physical address in the VC++ 6.0 environment? Pin
zhoufanking28-Jul-06 5:57
zhoufanking28-Jul-06 5:57 
QuestionRe: How to read/write a word from/to a certain physical address in the VC++ 6.0 environment? Pin
David Crow28-Jul-06 7:13
David Crow28-Jul-06 7:13 
AnswerRe: How to read/write a word from/to a certain physical address in the VC++ 6.0 environment? Pin
zhoufanking28-Jul-06 12:52
zhoufanking28-Jul-06 12:52 
GeneralRe: How to read/write a word from/to a certain physical address in the VC++ 6.0 environment? Pin
Gary R. Wheeler28-Jul-06 16:08
Gary R. Wheeler28-Jul-06 16:08 
AnswerRe: How to read/write a word from/to a certain physical address in the VC++ 6.0 environment? Pin
A_Fa28-Jul-06 18:51
A_Fa28-Jul-06 18:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.