473,405 Members | 2,171 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,405 software developers and data experts.

How to store incoming packets or how to allocate pool of free space for the packets?

I am doing a project in embedded system (in vc++.net 2003)...I need to allocate a pool of free space for the incoming packets.Once i received the packet in the pool, an intimation must be given to me that the requested packet has come.How to do this?

Meanwhile, an packet comes for another process which runs in the backend,an intimation must be given for that process.I know, it is possible by multithreading. I need some ideas, how to implement this? How to generate the intimation? Awaiting for the response...
Jul 16 '08 #1
4 2072
Nepomuk
3,112 Expert 2GB
Do you want to do this in C++? Then please post your question in the C/C++ Forum. If it's in .NET, use the .NET Forum. The Experts there will be happy to help you.

Greetings,
Nepomuk
Jul 16 '08 #2
I don’t have any idea about,how this can be implemented in Vc++. The general techniques are as follows.
Lets assume two process A and B. A is the one which collects packets and it intimates to Process B to process it.

Semaphore var = 0;
Queue q

Process B() {
Lock semaphore(var); //here is a wait until process A unlocks
read from a Q(q);
Do your work.
}


Process A(){
Do your work;
write into a Q(q);
Unlock semaphore(var);
}
Regards,
Arul
Jul 16 '08 #3
Hi...
I have some doubts in your reply. Whenever the data comes, How the process B, knows the data is available in the stream..

I think the process done by Process B are
1. Check for the data available in the stream.
2. If the data is available, then check for the free space available in the pool.
Then get the data from the stream, copy the data to the pool of free space
3. then, at last, give an intimation to the process A.
4. if the data in the pool, is taken by process A, then Log the data in a file.
5. wait for the data

Am i correct?
Jul 17 '08 #4
Hi...
I have some doubts in your reply. Whenever the data comes, How the process B, knows the data is available in the stream..

I think the process done by Process B are
1. Check for the data available in the stream.
2. If the data is available, then check for the free space available in the pool.
Then get the data from the stream, copy the data to the pool of free space
3. then, at last, give an intimation to the process A.
4. if the data in the pool, is taken by process A, then Log the data in a file.
5. wait for the data

Am i correct?
Now i bit clear about what you want to do....


/* semaphore is used to give a signal to another process here */

Semaphore var = 0; /* var semaphore is locked, which means some
has to unlock it, then only any one can lock it.*/

Semaphore var1 = 1; /* any one can do semaphore lock *.*/

Queue q /* it used to pass information b/w two process */

Process B() {

while(1){
Lock semaphore(var); /* here is Process B becuse 'var=0' this var can be 1, when
process A executes 'Unlock semaphore(var);'
Means that process a after completes it work, it send a signal
to process B.
i.e waiting for a signal from process 'A'*/
read from a Q(q); /* Once the process 'A' unlocks Process 'B' reads from the Q
Note Now Process B is process processing but Process is locked
by semaphore var1 . until some one else unlock the semaphore
Process 'A' can not be continue*/

Unlock semaphore(var1);/* Okay Process 'B' took informtaion from the Q, so it has
Enoguh informtion to proceed, Now it can unlock the send a
signal to Process 'A' to continue by unlocking the semaphore
'var1' Unlock semaphore(var1)
Send a signal to process 'A'*/
Do your work. /* do your work*/
} /* end while */
}


Process A(){
while (1){
Lock semaphore(var1) /* var1=1 so process a can get lock...., it will not wait for anything
first time..., Note it is not unlock this semaphore..., which
second third etc it can not lock again, some one has to unlock
it then only it can lock 2nd and 3rd time.
Who is unlocking it, it done by Process 'B' i.e just receving
signal to Process 'B' to continue
*/
Do your work; /* Do your work */
write into a Q(q); /* write into a Q */
Unlock semaphore(var); /* var was 0, Now unlock this semaphore leads var=1, so process B
can continue becuse Proceess 'B' 'Lock semaphore(var);' process
A to unlock. it is signal sending a signal to process B
to continue */

}
}

Feel free to discuss more on this.....
Regards,
Arul
Jul 18 '08 #5

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

Similar topics

1
by: John Dalberg | last post by:
I am getting a "Could not allocate space for object 'temp_trc' in database 'Test' because the 'PRIMARY' filegroup is full" The database test has unrestricted growth (All the defaults). It resides...
5
by: lixiaoyao | last post by:
hi all I use matrix & vector function to allocate the space myself in c, typedef struct matrix_array newdata; struct matrix_array{ float **sy,*sxx; }; newdata ndata;//new data struct...
4
by: Brian Rice | last post by:
I have a socket application that is sending and receiving packets asynchronously. It works great except, when I receive packets that are larger than my receive buffer which then generate several...
3
by: Geof | last post by:
Hello, I need to write an application to monitor incoming UDP packets on a specific port. This UDP port is already in use by a third party application. The goal is : to execute some code...
1
by: | last post by:
I cannot handle this.I can receive incoming but I cannot detect outgoing packets. I am using Windows XP no SP present. Thanks a lot for answers.
5
by: Björn Olsson | last post by:
Hello All. If I where to capture network traffic, dropping packets and modifying packets. I.e write firewall functionality. Which API or SDK would be the correct choice? I would prefer to do it...
20
by: ramasubramanian.rahul | last post by:
hi folks i have a peculiar problem. i have to allocate more than size_t consequtive bytes on a system . after i do a malloc .. i am unable to do a realloc because it takes size_t as a new size...
3
by: selvialagar | last post by:
I am doing a project in embedded system (in vc++.net 2003)...I need to allocate a pool of free space for the incoming packets.Once i received the packet in the pool, an intimation must be given to me...
7
by: Nash | last post by:
Hi, I have a Client and Server application which does communication using sockets(APM). The problem is Whenever the client is connected to a server i am storing the socket in a list. When...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.