-
Notifications
You must be signed in to change notification settings - Fork 71
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
sqlite: Initial port #417
base: loader
Are you sure you want to change the base?
sqlite: Initial port #417
Conversation
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
@@ -31,7 +34,7 @@ libc_syscall_override(cos_syscall_t fn, int syscall_num) | |||
cos_syscalls[syscall_num] = fn; | |||
} | |||
|
|||
struct sl_lock stdout_lock = SL_LOCK_STATIC_INIT(); | |||
//struct sl_lock stdout_lock = SL_LOCK_STATIC_INIT(); |
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.
Is there demand for a single threaded version of this? Removing all this synchronization logic is going to lead to weird bugs as soon as you have more than one thread. Why doesn't it work as-is? Too tight coupling to SL?
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.
Great question, and good intuition. We revamping libposix right now to use a generic interface that can either be co-located (via library) with sl, or accessed in another component. Given this, most of the synchronization facilities (and sl dependencies) in posix need to change backing APIs.
As such, Bite is trying to get sqlite working for a comparison case, and is not trying to solve other problems for now. As we update posix, I'm hoping we can add back in those features.
A lot of the cruft assuming single-component runtimes has been removed, but we have more to do, and libposix is one of the big places more love needs to be applied.
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.
I think that a lot of your changes are in the sqlite repo. How do you want to proceed with that. See my comment about having a main branch that tracks sqlite's upstream.
Some comments about how to avoid losing all of the sync and futex code.
@@ -4,3 +4,6 @@ | |||
[submodule "src/components/lib/ck/ck"] | |||
path = src/components/lib/ck/ck | |||
url = https://github.com/gwsystems/ck.git | |||
[submodule "src/components/lib/sqlite/sqlite"] |
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'll want to move this into gwsystems. Remember, we want the main branch of the repo be unmodifed, and have a cos
branch that we pull in as a submodule. That way we have a path for updating the code as upstream changes.
@@ -0,0 +1,9 @@ | |||
## tests | |||
|
|||
This is the skeleton interface used by the `mkcomponent.sh` script to aid in the creation of a new component. |
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.
Add documentation here, or remove the file.
{ | ||
} | ||
|
||
int result_print(void *v, int argc, char **argv, |
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.
your line width wraparound seems too aggressive. I don't think that the argument needs to be on another line.
#include <cos_defkernel_api.h> | ||
|
||
void | ||
cos_init(void) |
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.
If you remove this function, it should still work. If you don't have code in it, remove it!
int | ||
main(void) | ||
{ | ||
printc("Calling sqlite functions\n"); |
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.
inconsistent indentation styules. likely mixing spaces and tabs.
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.
variable definitions should be at the top of the block.
completed_successfully = sl_thd_block_timeout(0, wakeup_deadline); | ||
wakeup_time = sl_now(); | ||
//wakeup_deadline = sl_now() + sl_usec2cyc(time_to_microsec(req)); | ||
wakeup_deadline = 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.
I don't think that silently failing is the best policy here. We should probably fail loudly if a function that we don't support is called. BUG(), assert(0), after a printc to explain. etc...
I don't trust client checking for ENOTSUP
which would be the normal solution. Failure is more appropriate if it isn't supported here.
@@ -263,23 +272,27 @@ cos_set_tid_address(int *tidptr) | |||
* }; | |||
*/ | |||
|
|||
void* backing_data[SL_MAX_NUM_THDS]; | |||
//void* backing_data[SL_MAX_NUM_THDS]; | |||
void* backing_data[1]; |
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.
COS_NUM_THREADS
, I think???
@@ -291,11 +304,13 @@ cos_clone(int (*func)(void *), void *stack, int flags, void *arg, pid_t *ptid, v | |||
return -1; | |||
} | |||
|
|||
struct sl_thd * thd = sl_thd_alloc((cos_thd_fn_t) func, arg); | |||
//struct sl_thd * thd = sl_thd_alloc((cos_thd_fn_t) func, arg); | |||
struct sl_thd * thd = 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.
This shouldn't compile, right? Where is the defn of sl_thd
coming from here?
assert(0); | ||
} | ||
|
||
/* TODO: Cleanup empty futexes */ | ||
|
||
struct sl_lock futex_lock = SL_LOCK_STATIC_INIT(); | ||
//struct sl_lock futex_lock = SL_LOCK_STATIC_INIT(); | ||
|
||
/* | ||
* precondition: futex_lock is taken | ||
*/ | ||
int | ||
cos_futex_wait(struct futex_data *futex, int *uaddr, int val, const struct timespec *timeout) | ||
{ |
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.
This is all pretty challenging logic that Gregor spent a lot of time on. What I'd like: create an issue with a link to the commit in which this is removed, so that we can know how to easily bring back this code when hook up posix to the rest of the system.
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.
I think there have to be ways to do this that don't sacrifice correctness. (ie that fault instead of being unsafe concurrently) I'm always nervous leaving things in a subtly broken state--it's easy to forget the exact brokenness and put yourself in debugging hell for no reason later
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.
Great point.
Perhaps we replace the current lock implementation with something that simply errors out on contention:
struct lock {
unsigned long owner;
};
struct lock global_lock = (struct lock) { .owner = 0 };
void
lock_take(void) {
// failure here indicates that you're using concurrency/parallelism, which posix doesn't yet support!
if (!ps_cas(&global_lock.owner, 0, cos_thdid())) assert(0);
}
void
lock_release(void) {
// failure here indicates unpaired take and release.
assert(global_lock.owner == cos_thdid());
ps_store(&global_lock.owner, 0);
}
Replace normal lock behavior which requires contention management with simple "error out".
@@ -0,0 +1,9 @@ | |||
## sqlite | |||
|
|||
This is the skeleton library used by the `mklib.sh` script to aid in the creation of a new library. |
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.
documentation or remove.
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Signed-off-by: msdx321 <[email protected]>
Summary of this Pull Request (PR)
Add description here.
Intent for your PR
Choose one (Mandatory):
Reviewers (Mandatory):
(Specify @<github.com username(s)> of the reviewers. Ex: @user1, @user2)
Code Quality
As part of this pull request, I've considered the following:
Style:
Code Craftsmanship:
Testing
I've tested the code using the following test programs (provide list here):