Wednesday, February 26, 2020, 11:15:14 AM, Richard Hipp <d...@sqlite.org> wrote:

> On 2/25/20, Peter Kolbus <peter.kol...@gmail.com> wrote:
>> I noticed that sqliteDefaultBusyCallback() seems to depend directly on the
>> OS (behave differently based on SQLITE_OS_WIN||HAVE_USLEEP).  Since the
>> underlying primitive, sqlite3OsSleep(), actually uses the VFS to sleep, and
>> unixSleep() also has a roundup to whole seconds when HAVE_USLEEP is not
>> defined, any time resolution limitations are already handled there. And when
>> a custom VFS is configured, that VFS may well be able to sleep in milli or
>> microseconds using an RTOS-specific function that is not usleep() — for
>> example FreeRTOS has osDelay().
>>
>> Is there a reason sqliteDefaultBusyCallback() has this dual implementation,
>> and defining HAVE_USLEEP is correct to get better performance on platforms
>> that don’t have usleep()? Or could it be simplified?
>>

> I don't think I understand the question.  It sounds like you are
> asking why SQLite does not try to sleep for sub-second intervals on
> systems that do not support usleep()?

I've not looked at the source, so I don't know whether what I think
Peter is saying is correct or not, but what I THINK Peter is implying
there's POSSIBLY some decision (based on HAVE_USLEEP) in the "core"
SQLite code about what sort of timeout to ask for, before the request
gets handed over to the VFS to implement.

Presumably, in the default VFS implementation(S) this also uses
HAVE_USLEEP to decide whether sub-seconds times are possible or not.

However, a custom VFS may have its own way of implementing sub-second
delays (but does not implement usleep() itself)... it could therefore
honour a request for sub-second delay if asked. However, to be asked,
it has to "lie" about supporting usleep() and define HAVE_USLEEP.

It may simply be a concern over semantics: i.e. whether HAVE_USLEEP
means ("implements the function usleep()" vs. "can do short delays
somehow") or it might be a deeper problem in that if you define
HAVE_USLEEP (to allow a custom VFS to be asked to sleep for short
amounts) it also causes other parts of the SQLite code to try and use
usleep() when it isn't implemented).


Graham


_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to