Using QT5.15.2, the operating system for Ubuntu18.04 (run) under VmWare,
Write the following two through QSystemSemaphore synchronization process, will find unusual, this problem seems more serious (has confirmed that the program is no problem under the Windows operating system 10)
The server program:
QSystemSemaphore InvalidDataSysSemaphore (" TestKeyInvalid ", 1);
TestKeyValid QSystemSemaphore ValidDataSysSemaphore (" ");
Quint32 ReceiveTimeCount=0;
While (1)
{
If (ValidDataSysSemaphore. Acquire ())
{
ReceiveTimeCount++;
InvalidDataSysSemaphore. Release ();
If (ReceiveTimeCount>
=32765)QDebug (" waiting for success=% d ", ReceiveTimeCount);//here can only received 32767 times, behind will not receive, but to restart the program will continue to receive semaphore could somehow
}
The else
{
QDebug (" wait for mistakes, had been waiting times=% d ", ReceiveTimeCount);
break;
}
}
The client program:
TestKeyInvalid QSystemSemaphore InvalidDataSysSemaphore (" ");
TestKeyValid QSystemSemaphore ValidDataSysSemaphore (" ");
Quint32 SendTimeCount=0;
For (quint32 I=0; i<32769; I++)
{
If (InvalidDataSysSemaphore. Acquire ())
{
SendTimeCount++;
ValidDataSysSemaphore. Release ();
}
The else
{
QString STR=InvalidDataSysSemaphore. ErrorString ();//when sent to the 32768th, sent wrong, this tip out of the resources information
QDebug (" send error, has been sent=% d ", SendTimeCount);
break;
}
}
Appear after sent 32767 will not be able to send signals, don't know how to solve?