-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implicitly assuming 64bit architecture in pqueue implementation #388
Comments
To me it looks like the priority queue is currently only ever used to hold pointers. I think it's safe to just assume that the element size in the queue is 32 bits or 64 bits according to the architecture. Maybe we should see if everything compiles without errors or warnings once we remove any casts to |
Thanks, @petervdonovan, the priority queue data type is also used as the reaction index. And this hard-coded to be an |
Are you sure about that? The reaction index is being accessed as a field of a reaction struct.
pqueue_pri_t get_reaction_index(void *reaction) {
return ((reaction_t*) reaction)->index;
} This is being passed into the pqueue implementation as the
env->reaction_q = pqueue_init(INITIAL_REACT_QUEUE_SIZE, in_reverse_order, get_reaction_index,
get_reaction_position, set_reaction_position, reaction_matches, print_reaction);
// Initialize the reaction queues
((pqueue_t**)scheduler->triggered_reactions)[i] =
pqueue_init(queue_size, in_reverse_order, get_reaction_index,
get_reaction_position, set_reaction_position,
reaction_matches, print_reaction);
I think we probably cannot fit the reaction data type into 32 bits because we are already doing some bit-cramming here.
// Reaction queue ordered first by deadline, then by level.
// The index of the reaction holds the deadline in the 48 most significant bits,
// the level in the 16 least significant bits. |
As I am turning on all warnings and treating them as errors I am seeing some odd things with the pqueue implementation. Basically, there is casting between
unsigned long long
which typically are 64 bit, andvoid *
which are 32bit or 64bit depending on the architecture. I am specifically talking about the static functions at the top of pqueue_tag.cE.g. in
pqueue_tag_get_priority
we assume that a void* can hold unsigned long long, this is not true on 32bit archs. Does anyone have a good handle on how the pqueue works?In
pqueue_init
we can see that it allocates only memory for a void* for each element (i.e. 64bit or 32bit depending on arch).It suggests that we either must explicitly have elements which have the desired size (64bit) or we must make do with 32bit priorities for the 32bit platforms.
Any thoughts @lhstrh @edwardalee @petervdonovan ?
The text was updated successfully, but these errors were encountered: