Currently, there are a couple MRs open that aim to add resource synchronization locking protocols to RTEMS that can be used by semaphores. Each locking protocol has a yes/no bit in the overall RTEMS attributes mask, but to extend support for more locking protocols in the future, a 2-3 bits semaphore kind mask has been proposed here: !882. More discussion in !1358 as well.
A 3-bit mask gives up to 8 locking protocol options. One of those options would be no protocol of course (000), but then each specific locking protocol (ICPP, PIP, MrsP, etc.) would have its own unique 3-bit pattern.
I’m interesting in knowing what the community thinks of this approach and about any other points to consider as well!
Given the expectation that an application would only use one specific/chosen multiprocessor locking protocol, I think it makes the most sense to choose that protocol either during RTEMS configuration (config.ini) or else during the application configuration (confdefs style). Either way, this would permit using the MrsP bit as an indicator to use the configured multiprocessor locking protocol for the instantiated semaphore at creation time.
There are probably additional pros/cons to consider in comparing config.ini vs confdefs approaches. The main one is whether deferring the choice of multiprocessor locking protocol to the application is needed.
There are other considerations such as the ramifications for testing: with config.ini appoach you need to rebuild RTEMS just to test different locking protocols. As a thought experiment, consider whether the existing mrsp tests would still work if you configured MPCP instead of MrsP? If not, then it means the tests have to be restructured anyway to accommodate the config.ini approach. However the confdefs approach would allow you to test MrsP and MPCP with the same built RTEMS, while it expands the number of smp tests overall.
I think you bring up a good point about the testing. With the config.ini approach, the the existing MrsP tests would certainly not work when configured with MPCP, since the MrsP test cases look for behaviors that are specific to MrsP (busy-waiting, temporary task migration, etc.) that MPCP does not have.
My preference is actually leaning towards the confdefs approach since there wouldn’t need to be so much to modify in the existing MrsP tests and has less ramifications than the config.ini in my opinion. Also, I do think the config.ini approach is a bit overkill since it changes what code gets included in each build of RTEMS, but the code for each locking protocol is pretty small.
Could you expand on more on how the confdefs approach would expand the number of SMP tests? The way I see it, each SMP locking protocol already needs at least one set of test cases (smpmrsp01, smpmpcp01, etc.), meaning that each locking protocol configuration would then also be included a different SMP test.
The confdefs approach requires separate tests configured for each locking protocol. But as you said, this is needed anyway, since the tests have some implementation-specific behavior they exercise. I agree with pursuing the confdefs approach.