Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!mcnc!uvaarpa!umd5!cvl!elsie!nih-csl!keith From: keith@nih-csl.UUCP (keith gorlen) Newsgroups: comp.lang.c++ Subject: Corrections to OOPS class library Message-ID: <302@nih-csl.UUCP> Date: 28 Jan 88 16:54:59 GMT Organization: NIH-CSL, Bethesda, MD Lines: 57 Keywords: C++,OOPS Object-Oriented Program Support Class Library Corrections 28-Jan-88 Class SharedQueue: If a SharedQueue is full the function SharedQueue::printOn() doesn't print the objects in the queue. This bug occurs in all versions of OOPS sent out before 28-Jan-88. Here is a corrected version of SharedQueue::printOn(): void SharedQueue::printOn(ostream& strm) { strm << className() << "(\n"; strm << "valueAvailable " << valueAvailable; strm << "spaceAvailable " << spaceAvailable; strm << "queue:\n"; int i = readPosition; for (int n = valueAvailable.value(); n>0; n--) { queue[i++]->printOn(strm); strm << "\n"; if (i == queue.capacity()) i = 0; } strm << ")\n"; } Class Semaphore: On 30-Dec-87 Semaphore::signal() was changed. A parameter "n" was added to signal the next "n" waiting processes, but the change caused a signal(1) to incorrectly increment "count" by 2 if "count" was 0. This problem occurs in all versions of OOPS sent out between 30-Dec-87 and 28-Jan-88. Here is a corrected version of Semaphore::signal(): void Semaphore::signal(unsigned n) { if (n == 0) return; AST_DISABLE; register Process* next; while (count<0 && n>0) { next = (Process*)waitList.removeFirst(); if (next->state() != TERMINATED) { next->resume(); n--; } count++; } count += n; AST_ENABLE; } -- Keith Gorlen phone: (301) 496-5363 Building 12A, Room 2017 uucp: uunet!ncifcrf.gov!nih-csl!keith National Institutes of Health Internet: keith%nih-csl@ncifcrf.gov Bethesda, MD 20892