Skip to content
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

Patina PR #410

Open
wants to merge 13 commits into
base: loaderarm
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,47 @@

/* lo and hi is actually running at the same prio */
#define ITERATION 10000
/* #define PRINT_ALL */
#define PRINT_ALL

thdid_t yield_hi = 0, yield_lo = 0;

volatile cycles_t start;
volatile cycles_t end;
volatile int count;

struct perfdata perf;
cycles_t result[ITERATION] = {0, };

/***
* We're measuring 2-way context switch time.
* We're measuring one-way context switch time.
*/
void
yield_hi_thd(void *d)
{
/* Never stops running; low priority controls how many iters to run. */
while (1) {
cycles_t end;

while (count < ITERATION) {
debug("h1,");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know you didn't add this code, but there is no reason to keep meaningless printouts in the code. Feel free to remove them.


start = time_now();
sched_thd_yield_to(yield_lo);
end = time_now();

debug("h2,");

perfdata_add(&perf, end - start);

count++;
}

while (1) ;
}

void
yield_lo_thd(void *d)
{
int i;
int first = 0;
cycles_t end;

for (i = 0; i < ITERATION + 1; i++) {
while (count < ITERATION) {
debug("l1,");

start = time_now();
Expand All @@ -55,16 +66,16 @@ yield_lo_thd(void *d)

debug("l2,");

if (first == 0) first = 1;
else perfdata_add(&perf, end - start);
perfdata_add(&perf, end - start);

count++;
}

perfdata_calc(&perf);
#ifdef PRINT_ALL
perfdata_all(&perf);
#else
perfdata_print(&perf);
perfdata_raw(&perf);
#endif
perfdata_calc(&perf);
perfdata_print(&perf);

while (1) ;
}
Expand All @@ -77,6 +88,8 @@ test_yield(void)
SCHED_PARAM_CONS(SCHEDP_PRIO, 6)
};

count = 0;

perfdata_init(&perf, "Context switch time", result, ITERATION);

printc("Create threads:\n");
Expand Down
37 changes: 25 additions & 12 deletions src/components/implementation/tests/bench_sl_yield/bench_sl_yield.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

/* lo and hi is actually running at the same prio */
#define ITERATION 10000
/* #define PRINT_ALL */
#define PRINT_ALL

/* Ensure this is the same as what is in sl_mod_fprr.c */
#define SL_FPRR_NPRIOS 32
Expand All @@ -32,29 +32,40 @@ struct sl_thd *testing_thread;
thdid_t thdid1, thdid2;

volatile cycles_t start;
volatile cycles_t end;
volatile int count;

struct perfdata perf;
cycles_t result[ITERATION] = {0, };

static void
thd1_fn()
{
/* Never stops running; low priority controls how many iters to run. */
while (1) {
cycles_t end;

while (count < ITERATION) {
debug("h1,");

start = time_now();
sl_thd_yield(thdid2);
end = time_now();

debug("h2,");

perfdata_add(&perf, end - start);

count++;
}

while (1);
}

static void
thd2_fn()
{
int i;
int first = 0;
cycles_t end;

for (i = 0; i < ITERATION + 1; i++) {
while (count < ITERATION) {
debug("l1,");

start = time_now();
Expand All @@ -63,16 +74,16 @@ thd2_fn()

debug("l2,");

if (first == 0) first = 1;
else perfdata_add(&perf, end - start);
perfdata_add(&perf, end - start);

count++;
}

perfdata_calc(&perf);
#ifdef PRINT_ALL
perfdata_all(&perf);
#else
perfdata_print(&perf);
perfdata_raw(&perf);
#endif
perfdata_calc(&perf);
perfdata_print(&perf);

while (1) ;
}
Expand Down Expand Up @@ -104,6 +115,8 @@ cos_init(void)
struct cos_defcompinfo *defci = cos_defcompinfo_curr_get();
struct cos_compinfo *ci = cos_compinfo_get(defci);

count = 0;

PRINTC("Thread switch benchmark for the scheduling library (sl)\n");
cos_meminfo_init(&(ci->mi), BOOT_MEM_KM_BASE, COS_MEM_KERN_PA_SZ, BOOT_CAPTBL_SELF_UNTYPED_PT);
cos_defcompinfo_init();
Expand Down
18 changes: 18 additions & 0 deletions src/components/implementation/tests/patina_chan_bench/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Required variables used to drive the compilation process. It is OK
# for many of these to be empty.
#
# The set of interfaces that this component exports for use by other
# components. This is a list of the interface names.
INTERFACE_EXPORTS =
# The interfaces this component is dependent on for compilation (this
# is a list of directory names in interface/)
INTERFACE_DEPENDENCIES =
# The library dependencies this component is reliant on for
# compilation/linking (this is a list of directory names in lib/)
LIBRARY_DEPENDENCIES = component patina ubench
# Note: Both the interface and library dependencies should be
# *minimal*. That is to say that removing a dependency should cause
# the build to fail. The build system does not validate this
# minimality; that's on you!

include Makefile.subsubdir
9 changes: 9 additions & 0 deletions src/components/implementation/tests/patina_chan_bench/doc.md
Original file line number Diff line number Diff line change
@@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a brief note here about what it actually does, or remove this file. The file has no value as it stands. (I know it was automatically created).

It provides no functionality, and should never be depended on!
This documentation should be *replaced* in the documentation for a new component.

### Description

### Usage and Assumptions
Loading