Click here to Skip to main content
15,904,156 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Fast Image Processing - programming language to use Pin
Alan Balkany23-Sep-09 3:19
Alan Balkany23-Sep-09 3:19 
GeneralRe: Fast Image Processing - programming language to use Pin
Tim Craig23-Sep-09 8:53
Tim Craig23-Sep-09 8:53 
GeneralRe: Fast Image Processing - programming language to use [modified] Pin
Amarnath S21-Sep-09 19:15
professionalAmarnath S21-Sep-09 19:15 
GeneralRe: Fast Image Processing - programming language to use Pin
Alan Balkany22-Sep-09 5:15
Alan Balkany22-Sep-09 5:15 
GeneralRe: Fast Image Processing - programming language to use Pin
Luc Pattyn22-Sep-09 5:35
sitebuilderLuc Pattyn22-Sep-09 5:35 
GeneralRe: Fast Image Processing - programming language to use Pin
CPallini24-Sep-09 21:12
mveCPallini24-Sep-09 21:12 
GeneralRe: Fast Image Processing - programming language to use Pin
Nagy Vilmos24-Sep-09 21:46
professionalNagy Vilmos24-Sep-09 21:46 
GeneralRe: Fast Image Processing - programming language to use Pin
CPallini24-Sep-09 21:57
mveCPallini24-Sep-09 21:57 
GeneralRe: Fast Image Processing - programming language to use Pin
Luc Pattyn25-Sep-09 2:59
sitebuilderLuc Pattyn25-Sep-09 2:59 
GeneralRe: Fast Image Processing - programming language to use [modified] Pin
CPallini25-Sep-09 9:28
mveCPallini25-Sep-09 9:28 
AnswerRe: Fast Image Processing - programming language to use Pin
Chris Losinger24-Oct-09 10:50
professionalChris Losinger24-Oct-09 10:50 
AnswerRe: Fast Image Processing - programming language to use Pin
novice__geek30-Oct-09 0:13
novice__geek30-Oct-09 0:13 
GeneralPagerank and its mathematics: Explanation needed Pin
kentipsy20-Sep-09 8:24
kentipsy20-Sep-09 8:24 
GeneralRe: Pagerank and its mathematics: Explanation needed Pin
Richard MacCutchan20-Sep-09 9:41
mveRichard MacCutchan20-Sep-09 9:41 
QuestionHow to manage a share buf array? Pin
donniehan18-Sep-09 0:04
donniehan18-Sep-09 0:04 
AnswerRe: How to manage a share buf array? Pin
Luc Pattyn18-Sep-09 2:32
sitebuilderLuc Pattyn18-Sep-09 2:32 
GeneralRe: How to manage a share buf array? Pin
donniehan18-Sep-09 4:06
donniehan18-Sep-09 4:06 
GeneralRe: How to manage a share buf array? Pin
Luc Pattyn18-Sep-09 4:15
sitebuilderLuc Pattyn18-Sep-09 4:15 
GeneralRe: How to manage a share buf array? Pin
donniehan18-Sep-09 13:43
donniehan18-Sep-09 13:43 
GeneralRe: How to manage a share buf array? Pin
Luc Pattyn18-Sep-09 14:48
sitebuilderLuc Pattyn18-Sep-09 14:48 
Hi,

no I have no experience with Postgres SQL, but that won't matter much I think.


donniehan wrote:
It takes very short time for each msg to be handled by master.


That is very good. It will be key to your system working well.

My simple design would consist of:
- a single Message class that will be instantiated a number of times; the instances will be recycled without loading the garbage collector.
- an "emptyCollection" holding a number of empty message objects; think of it as a queue, although other kinds of collections could work too.
- an "emptyLock" object used to guard operations on emptyCollection;
- a "filledCollection" holding a number of filled message objects; again think of it as a queue.
- a "filledLock" object used to guard operations on filledCollection.
- emptyCollection+emptyLock and filledCollection+filledLock could be two instances of a single class MySafeCollection.

The initialization code would create a sufficient number of message instances and put them in the emptyCollection; the filledCollection is still empty.

Then the system really starts and performs these steps:
1. the producers obtain a message object quickly (getting one from emptyCollection, this must be protected by locking on emptyLock, which never will take long);
2. let the producer fill the message object;
3. let the producer put its filled message into the "filledCollection", using the filledLock, which again will not take long.
4. let the consumer obtain a filled message object from the filledCollection(again shortly using the filledLock).
5. let the consumer process the message; as this is a short operation and should never become a bottleneck I would consider doing this on a thread with slightly higher priority.
6. let the consumer return the message to the "emptyCollection" using the emptyLock.

Possible refinements:
A. You still need a signaling mechanism: each time a producer adds something to the filledCollection, it should send a signal to the single consumer, so it goes and fetches one (or more) messages from the filledCollection. This avoids the need for a polling loop in which the consumer would waste CPU cycles when no messages got filles.
B. A producer needing a message object and not finding one in the "emptyCollection" could create a new one; that would make the initialization unnecessary, however when things go terribly wrong, you may end up with a huge number of messages in the filledCollection.

I have implemented the above scheme numerous times inside embedded systems (i.e.using a proprietary operating system, not .NET or Windows). I know it works very well and is very performant.

Smile | :)

Luc Pattyn

Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.

Local announcement (Antwerp region): Lange Wapper? Neen!


GeneralRe: How to manage a share buf array? Pin
donniehan20-Sep-09 18:03
donniehan20-Sep-09 18:03 
GeneralRe: How to manage a share buf array? [modified] Pin
Luc Pattyn21-Sep-09 1:17
sitebuilderLuc Pattyn21-Sep-09 1:17 
GeneralRe: How to manage a share buf array? Pin
donniehan21-Sep-09 2:00
donniehan21-Sep-09 2:00 
GeneralRe: How to manage a share buf array? Pin
Luc Pattyn21-Sep-09 2:07
sitebuilderLuc Pattyn21-Sep-09 2:07 
QuestionHough Circular transform Pin
lcssiva16-Sep-09 1:38
lcssiva16-Sep-09 1:38 

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.