[AGENT++] AGENT++ 4.1.2 the PTHREAD_MUTEX_ERRORCHECK does not work right?

Frank Fock fock at agentpp.com
Sat Oct 27 02:01:11 CEST 2018


Hi Claus,

I do not know what you are trying to test and what you want to achieve with the tests?
You seem to be expecting some behaviour from the AGENT++ Synchronized class that it cannot provide and that is not defined in its interface contract (see the API documentation). I have to admit, that the Synchronized::try lock() documentation should read as follows
	/**
	 * Try to enter a critical section. If this thread owned this
         * lock already, the call succeeds too, but there
         * will not be recursive locking. Unlocking will always free the lock. 
	 *
	 * @return
	 *     LOCKED if there was no lock before and now the calling thread
         *     owns the lock; BUSY = if another thread owns the lock;
         *     OWNED if the lock is already owned by the calling thread.
         *     Note: OWNED will never be returned with POSIX threads and 
         *     ERRORCHECK enabled, instead EBUSY is returned if the current
         *     thread already owns the mutex.
	 */
I have added the last sentence starting with “Note:” in the current code base meanwhile. 
However, as C/C++ developer using PTHREADS, you should be aware, that it is not possible to detect non-blocking if a mutex is owned by the current or another thread when using ERRORCHECK mutexes. How should Synchronized do this magic if the operating system cannot provide it?

Some of the other tests you implemented, do not match with the description of the used function(s). 

You wrote, you have doubts on the code quality of AGENT++ and SNMP++. Then why are you trying to use/test it? Using PTHREADS directly would be much easier for your test scenario?
I have doubts too, but in you testing. Before testing, you should always exactly know, what you would like to achieve with the tests. Without that baseline, it would not help (anyone).

Why didn’t you name the systems which showed different behaviour? Which OS, version, AGENT++ version, compiler, and what differences, of course?

Regards,
Frank


> On 26. Oct 2018, at 19:56, Claus Klein <claus.klein at arcormail.de> wrote:
> 
> Hi agentpp users, no response since about a month?
> 
> Why is nobody interesting in my problem?
> 
> 
> The PTHREAD_MUTEX_ERRORCHECK works fine with posix threads, but the Agentpp::Synchronized class NOT!
> See too http://man7.org/linux/man-pages/man3/pthread_mutex_lock.3p.html
> 
> 
> Why is there a different behavior on each system?
> Is this indented?
> 
> Exists a unit test program for the agent++ and snmp++ library?
> Are there continuous integration tests on different platforms and with different compilers?
> 
> 
> I have more and more questions about the quality of the library code.
> ====================================================
> 
> 
> By the way, it does not compile with C++17!
> 
> 
> On Windows7 with VS2017, my tests run without errors, but on MSYS2 NOT (with posix threads)!
> 
>> Am 01.10.2018 um 10:34 schrieb Claus Klein <claus.klein at arcormail.de>:
>> 
>> Is the expectation wrong?
>> 
>> With AGENTPP_PTHREAD_RECURSIVE defined, my test works fine on my macbook with:
>> 
>> Darwin Claus-MBP.fritz.box 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 21 20:07:40 PDT 2018; root:xnu-3248.73.11~1/RELEASE_X86_64 x86_64 i386 MacBookPro5,1 Darwin
>> 
>> Best regards
>> Claus
> 
> _______________________________________________
> AGENTPP mailing list
> AGENTPP at agentpp.org
> https://oosnmp.net/mailman/listinfo/agentpp



More information about the AGENTPP mailing list