Skip to content

Conversation

kaspar030
Copy link
Contributor

clist was doubly linked in order to enable removal of threads from a run queue in constant time.

Today I realized that only the currently running thread can remove itself from a running queue (by blocking for a msg, mutex, sleeping, ...), and a singly linked but circular list offers O(1) removal of the head element.
So I changed clist accordingly.

This carves off 4 byte of tcb and increases context switch time performance by ~4%.

Waiting for #4557.

@kaspar030 kaspar030 added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: core Area: RIOT kernel. Handle PRs marked with this with care! labels Feb 29, 2016
@kaspar030 kaspar030 added the State: waiting for other PR State: The PR requires another PR to be merged first label Feb 29, 2016
@OlegHahm
Copy link
Member

Nice!

@haukepetersen
Copy link
Contributor

I like!

@@ -16,7 +16,8 @@

#define TEST_CLIST_LEN (8)

static clist_node_t tests_clist_buf[TEST_CLIST_LEN];
static list_node_t tests_clist_buf[TEST_CLIST_LEN];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below: the datatype is called list now so the variable, function and file names should reflect that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if clist_*() works with list_node_t objects?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But doesn't clist stand for circular list? (or is it that still)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I shared the list node definition between the two header files. Now I copied the definition, do you prefer it that way?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why copy when you can

typedef list_t clist_t;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typedef'ed it is now.

@kaspar030
Copy link
Contributor Author

  • rebased
  • made clist.h independent from list.h

@miri64
Copy link
Member

miri64 commented Mar 12, 2016

Why does this depend on #4557? This data structure should be independent of that change, right?

@kaspar030
Copy link
Contributor Author

Why does this depend on #4557? This data structure should be independent of that change, right?

#4557 introduces link.h. With copying the struct, this PR was independent. With the typedef, it's not.

@miri64
Copy link
Member

miri64 commented Mar 12, 2016

Why can't you take the list.h introduction over here and make #4557 dependent on this PR. That seems to be the more logical dependency graph to me.

@kaspar030
Copy link
Contributor Author

The perfect graph would be a "list.h" introduction PR, and then #4557 and this. Moving the list.h introduction here just shuffles the imperfect graph solution here.

I'd prefer merging #4557, then merging this.

@kaspar030 kaspar030 added this to the Release 2016.04 milestone Mar 21, 2016
@OlegHahm
Copy link
Member

Dependency not yet merged. Postponed.

@OlegHahm OlegHahm modified the milestones: Release 2016.07, Release 2016.04 Mar 28, 2016
@kaspar030
Copy link
Contributor Author

Sad.

@OlegHahm
Copy link
Member

Agreed, but currently I don't see realistic chances for #4557 to get merged until tomorrow. Do you disagree?

@kaspar030
Copy link
Contributor Author

Can't review it myself...

@OlegHahm
Copy link
Member

You can kick your reviewers. ;)

*
* Each list is represented as a "clist_node_t". It's only member, the "next"
* pointer, points to the last entry in the list, whose "next" pointer points to
* the first entry.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something reads weird here, how about

... . It's only member, the "next" pointer, points to the next entry in the list. The last element's "next" pointer points to the first entry.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missread the sentence, never mind...

@miri64
Copy link
Member

miri64 commented Mar 29, 2016

Needs rebase.

@kaspar030 kaspar030 removed the State: waiting for other PR State: The PR requires another PR to be merged first label Mar 29, 2016
@kaspar030
Copy link
Contributor Author

  • rebased, squashed

@haukepetersen haukepetersen added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 29, 2016
@haukepetersen
Copy link
Contributor

Code looks good, works as expected (on 'native' and some ARM boards), code size is smaller than before -> ACK!

@cgundogan
Copy link
Member

code looks sensible and changes make sense. ACK

@kaspar030 kaspar030 modified the milestones: Release 2016.04, Release 2016.07 Mar 29, 2016
@OlegHahm OlegHahm merged commit 07b1c94 into RIOT-OS:master Mar 29, 2016
@OlegHahm OlegHahm mentioned this pull request Mar 29, 2016
@kaspar030 kaspar030 deleted the optimize_clist branch February 7, 2017 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: core Area: RIOT kernel. Handle PRs marked with this with care! CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants