On 4/18/2023 6:58 AM, Nathan Hartman wrote:
On Tue, Apr 18, 2023 at 8:52 AM spudaneco <spudan...@gmail.com> wrote:
Perhaps you could use accessor functions to read/write 8, 16 32, 64 bit
values. Each scalar value will be properly aligned and, hence, will lie
within a page.
And those accessor functions could be macros in FLAT builds where functions
are not required, so no memory or code size increase.
Cheers
Nathan
The inefficiency is that each access would require a virtual to physical
address look-up. That could be alleviated by providing the base
physical address of the the page and the offset of the sem_t iin the
page as a parameter, maybe like:
struct paginfo_t pageinfo;
get_pageinfo(sem, &pageinfo);
value = get_pagevalue16(&pageinfo, &sem->field);
If the field like in the following page, then get_pagevalue16 would have
to work harder. But the usual case, where the sem_t lies wholly in the
page would be relatively fast.
This, however, would not macro-ize as well.
Not that no special alignment of the sem_t is required if you access by
scalar field.