Click here to Skip to main content
15,887,477 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Calculating a width and height, not square root. Pin
Yusuf8-Mar-09 1:50
Yusuf8-Mar-09 1:50 
GeneralHow to calculate width and height under constraints Pin
73Zeppelin7-Mar-09 19:53
73Zeppelin7-Mar-09 19:53 
GeneralRe: Calculating a width and height, not square root. Pin
Cloughy8-Mar-09 4:37
Cloughy8-Mar-09 4:37 
GeneralRe: Calculating a width and height, not square root. Pin
73Zeppelin9-Mar-09 0:12
73Zeppelin9-Mar-09 0:12 
QuestionVery advanced Computer Graphics library Pin
markweber5-Mar-09 5:08
markweber5-Mar-09 5:08 
AnswerRe: Very advanced Computer Graphics library Pin
Mark Churchill9-Mar-09 13:57
Mark Churchill9-Mar-09 13:57 
GeneralRe: Very advanced Computer Graphics library Pin
markweber10-Mar-09 3:26
markweber10-Mar-09 3:26 
Questiona parellel program problem Pin
JackPuppy2-Mar-09 1:49
JackPuppy2-Mar-09 1:49 
hi, there
It's my first time to post a question here to ask for help because the problem is drving me crazy. Everyone who give a direct answer or redirect-url resources is appreciable.

here is the problem:

I decide to grab web-pages from a website, what my policy is that I use a main thread to find many items in a page and i send each item to a thread to deal with. So this is a parallel muti-thread problem. and I find out that the whole process stuck somewhere and the usage of the CPU climed up to 100%. here is the main code that i think is asscociated:
<pre>
HANDLE hSemaThr,hSema,hContent;

main(){

....Handle hCont=CreateFile(....);
hSema=CREATESemaphore(0,1,1,0);
hSemaThr=CREATEMUTEX(0,10,10,0);//this Semaphore is to control thread-buildings so that there are 10 threads in the process at most
WHILE(regex_search(begin,end,stringmatch,r)){
string s=stringmatch[0];
begin=stringmatch[0].second;


WaitForSingleObject(hSemaThr,INFINITE);
CreateThread(0,0,Grab,(void*)dc,0,0);

}

CloseHandle(hCont);
}

void Grab(void* doc){

......
......

WaitForSingleObject(hSema,INFINITE);
if(!WriteFile(::hCont,lpBuf,(int)strlen(lpBuf),&lpN,0)){
cout < <"can't write file in thread" < <GetLastError() < <endl;
//system("pause");

}
ReleaseSemaphore(hSema,1,0);

WaitForSingleObject(hMutexThr,INFINITE);
CanThr--;
ReleaseSemaphore(hSemaThr,1,0);

}
</pre>
Can somebody help me!
Thanks very much!
AnswerRe: a parellel program problem Pin
JackPuppy2-Mar-09 2:43
JackPuppy2-Mar-09 2:43 
AnswerRe: a parellel program problem Pin
JackPuppy2-Mar-09 2:44
JackPuppy2-Mar-09 2:44 
QuestionGreedy problem with filling sequence Pin
proggged26-Feb-09 4:23
proggged26-Feb-09 4:23 
AnswerRe: Greedy problem with filling sequence Pin
Perisic, Aleksandar28-Feb-09 5:38
Perisic, Aleksandar28-Feb-09 5:38 
GeneralRe: Greedy problem with filling sequence Pin
Perisic, Aleksandar1-Mar-09 3:45
Perisic, Aleksandar1-Mar-09 3:45 
QuestionAnd Or and Xor with floating point Pin
PIEBALDconsult25-Feb-09 4:35
mvePIEBALDconsult25-Feb-09 4:35 
AnswerRe: And Or and Xor with floating point Pin
Dan Neely25-Feb-09 4:47
Dan Neely25-Feb-09 4:47 
GeneralRe: And Or and Xor with floating point Pin
supercat925-Feb-09 5:28
supercat925-Feb-09 5:28 
GeneralRe: And Or and Xor with floating point Pin
Dan Neely25-Feb-09 5:38
Dan Neely25-Feb-09 5:38 
GeneralRe: And Or and Xor with floating point Pin
supercat925-Feb-09 6:08
supercat925-Feb-09 6:08 
GeneralRe: And Or and Xor with floating point Pin
PIEBALDconsult25-Feb-09 6:48
mvePIEBALDconsult25-Feb-09 6:48 
QuestionCalculate intersection between arcs / lines and arc /arc Pin
sagaert21-Feb-09 8:12
sagaert21-Feb-09 8:12 
AnswerRe: Calculate intersection between arcs / lines and arc /arc Pin
Arash Partow21-Feb-09 16:40
Arash Partow21-Feb-09 16:40 
GeneralRe: Calculate intersection between arcs / lines and arc /arc Pin
sagaert22-Feb-09 3:13
sagaert22-Feb-09 3:13 
QuestionCaculate time left for data transfer Pin
cdpace17-Feb-09 6:21
cdpace17-Feb-09 6:21 
GeneralRe: Caculate time left for data transfer Pin
Luc Pattyn17-Feb-09 6:32
sitebuilderLuc Pattyn17-Feb-09 6:32 
GeneralRe: Caculate time left for data transfer Pin
cdpace17-Feb-09 11:30
cdpace17-Feb-09 11:30 

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.