VirtualBox

Opened 4 years ago

Last modified 4 years ago

#19818 awaitsfeedback enhancement

Use portable sched_yield() rather than pthread_yield()

Reported by: Harry M Owned by:
Component: guest additions Version: VirtualBox 6.1.10
Keywords: musl adelielinux Cc:
Guest type: Linux Host type: Linux

Description

The sched_yield() call is the standard and portable routine. Current calls to pthread_yield() in Virtualbox sources (host and guests) should be replaced by calls to sched_yield(). If sched_yield() is not available on a platform, then the build tools (including those for the Guest Additions) could arrange to use a shim routine that calls pthread_yield().

This would be helpful in supporting platforms that do provide support for non-portable libraries and routines.

Change History (2)

comment:1 by aeichner, 4 years ago

Status: newawaitsfeedback

May I ask what the use case would be? Most platforms will need more changes anyway to be supported (drivers, etc.). From a quick grep the only places using pthread_yield() are:

src/VBox/Runtime/r3/posix/thread2-posix.cpp
src/VBox/Runtime/r3/posix/semevent-posix.cpp

These already contain defines to use sched_yield() on Solaris, FreeBSD, etc. so you can just add your platform when porting the runtime to it.

comment:2 by Harry M, 4 years ago

The binary blobs included with the Guest Additions do not run on a platform that does not provide non-portable and/or non-free software. We are trying to arrange for our compatibility library to provide a shim to have pthread_yield() call to sched_yield().

In the current case, this particular instance of incompatibility will be addressed, but as a practice, it might still be a good idea to conform with standards moving forward to avoid additional, similar issues. It would probably be advantageous to your application so as to provide portability to more target platforms.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use