Hello, Since last few days i am analyzing squid code for smp support, I found one big issue regarding debugs() function, It is very hard get rid of this issue as it is appearing at almost everywhere in the code. So for testing purpose i have disable the debug option in squid.conf as follows
------------------------------- debug_options 0,0 ------------------------------- Well this was only way, as did not want to spend time on this issue..... Now concentrating on locking mechanism... As OpenMP library is widely supported by almost all platforms and compilers, I am inheriting locking mechanism from the same Just include omp.h & compile code with -fopenmp option if using gcc, Other may use similar thing on their platform, Well that is not a big issue.. BUT, is it wise to take support from this library? Please discuss on this issue.... I felt it is really easy to manage threads and critical sections if we use OPENMP. AS DISCUSSED BEFORE...... AND details available on http://wiki.squid-cache.org/Features/SmpScale I think, I have solved SOME critical section problems in existing squid code. *****************AsyncCallQueue.cc******************************* void AsyncCallQueue::schedule(AsyncCall::Pointer &call) { #pragma omp critical (AsyncCallQueueLock_c) // HERE IS THE LOCK { if (theHead != NULL) { // append assert(!theTail->theNext); theTail->theNext = call; theTail = call; } else { // create queue from cratch theHead = theTail = call; } } //AND THEN AsyncCallQueue::fireNext() { AsyncCall::Pointer call; #pragma omp critical (AsyncCallQueueLock_c) // SAME LOCK { call = theHead; theHead = call->theNext; call->theNext = NULL; if (theTail == call) theTail = NULL; } .... } ITS WORKING, AS SAME CRITICAL SECTIONS (i.e AsyncCallQueueLock_c) CAN NOT BE CALLED SIMULTANEOUSLY ****************************************************************** Well in the same way following thing as appearing on /Features/SmpScale are also locked( May be incompletely) 1. hash_link ---- LOCKED 2. dlink_list ---- LOCKED 3. ipcache, fqdncache ---- LOCKED, 4. FD / fde handling ---WELL, SEEMS NOT CREATING PROBLEM, If any then please discuss. 5. statistic counters --- NOT LOCKED ( I know this is very important, But these are scattered all around squid code, Write now they may be holding wrong values) 6. memory manager --- DID NOT FOLLOW 7. configuration objects --- DID NOT FOLLOW AND FINALLY, Two sections in EventLoop.cc are separated and executed in two threads simultaneously as follows (#pragma lines added in existing code, no other changes) **************EventLoop.cc**************** #pragma omp parallel sections //PARALLEL SECTIONS { #pragma omp section //THREAD-1 { if (waitingEngine != NULL) checkEngine(waitingEngine, true); if (timeService != NULL) timeService->tick(); checked = true; } #pragma omp section //THREAD-2 { while(1) { if ( lastRound == true) break; sawActivity = dispatchCalls(); if (sawActivity) runOnceResult = false; if(checked == true) lastRound = true; } } } ******************************** May need deep testing , but it is working...... am I on the right path ? Thank you, -- Mr. S. H. Malave Computer Science & Engineering Department, Walchand College of Engineering,Sangli. [email protected]
