-
Notifications
You must be signed in to change notification settings - Fork 13
lib: bm_queue: a dynamic queue implementation #162
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why this needs heap? Tried it in firmware loader and got this:
E: ***** BUS FAULT *****
E: Precise data bus error
E: BFAR Address: 0x3fe24234
E: r0/a1: 0x20006678 r1/a2: 0x000000bf r2/a3: 0x0000001f
E: r3/a4: 0x3fe24234 r12/ip: 0x00000000 r14/lr: 0x000abeff
E: xpsr: 0x8900002d
E: Faulting instruction address (r15/pc): 0x000ae9b0
E: >>> ZEPHYR FATAL ERROR 25: Unknown error on CPU 0
E: Fault during interrupt handling
E: Halting system
upped heap to 32KiB (is 0 with the zephyr queue system) and get the same result:
->
so seems to be something wrong with this library, after switching back to the zephyr one the application runs flawlessly |
A dynamic queue implementation based on Zephyr's k_queue. The library has a compatibility mode to export Zephyr's k_queue API, but it also exposes its own bm_queue API set so that bare metal libraries and application can avoid including zephyr/kernel.h and using a k_ prefixed (kernel's) API. Signed-off-by: Emanuele Di Santo <[email protected]>
Thanks for giving it a try! I had a made a silly mistake, you should be able to get a bit further with it now. |
k_queue_alloc_append(&k, &i); | ||
k_queue_alloc_prepend(&k, &i); | ||
k_queue_append_list(&k, NULL, NULL); | ||
k_queue_merge_slist(&k, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note. Had to comment out this line when running the sample.
This function crashes because NULL
is not a valid value for input argument list
. sys_slist_is_empty(list)
blindly dereferences list
. This seems to be the same functionality as k_queue_merge_slist
in zephyr/kernel/queue.c
, it's just the usage here that is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I just added those to make sure they compiled :)
And indeed it did not need the heap, so I have removed that requirement. In case there is none then allocations just fail, but that's how it's supposed to work. |
Seems to work now |
* Copyright (c) 2016, Wind River Systems, Inc. | ||
* Copyright (c) 2025, Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the license, since this file is mostly copied from kernel.h and also modified, the modifications must be marked clearly. A link to the the source file in the commit message would also be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is marked * Copyright (c) 2025, Nordic Semiconductor ASA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are our modifications also covered by Apache-2.0 license, then, and not the Nordic 5-clause license?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can't relicense the file, it has to remain under the original license
A dynamic queue implementation based on Zephyr's k_queue. The library has a compatibility mode to export Zephyr's
k_queue
API, but it also exposes its ownbm_queue
API so that bare metal libraries and the application can avoid includingzephyr/kernel.h
and using a k_ prefixed (kernel's) API.Note, I couldn't write a unit test for this given that
UNITY
depends onMULTITHREADING
so I slapped the calls in a sample to check that it compiled, but haven't done much testing beyond that.I based this on Jamie's #155 .