Merge commit 'dc87e78590ea86615d3ebe90d23af4548445b941' into backend_devel
* commit 'dc87e78590ea86615d3ebe90d23af4548445b941': add a two-thread acquire test show the state of the thread in question minor fixes: remove an old comment and change another fix the prime test algorithm use unsigned long for even more digits!
This commit is contained in:
commit
f57d637b59
4 changed files with 23 additions and 19 deletions
|
|
@ -147,7 +147,6 @@ lumiera_threadpool_acquire_thread (enum lumiera_thread_class kind,
|
|||
return ret;
|
||||
}
|
||||
|
||||
// TODO: rename to lumiera_threadpool_park_thread
|
||||
void
|
||||
lumiera_threadpool_release_thread(LumieraThread thread)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ lumiera_thread_new (enum lumiera_thread_class kind,
|
|||
{
|
||||
pthread_once (&lumiera_thread_initialized, lumiera_thread_tls_init);
|
||||
|
||||
// TODO: do something with these:
|
||||
// TODO: do something with this string:
|
||||
(void) purpose;
|
||||
REQUIRE (attrs, "invalid pthread attributes structure passed");
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,17 @@ END
|
|||
|
||||
TEST "process a function" process-function <<END
|
||||
err: the input to the function is
|
||||
err: finished waiting
|
||||
err: the result is 1
|
||||
END
|
||||
|
||||
TEST "acquire two threads" two-thread-acquire <<END
|
||||
err: acquiring thread 1
|
||||
err: acquiring thread 2
|
||||
err: thread 1 kind=INTERACTIVE
|
||||
err: thread 1 state=IDLE
|
||||
err: thread 2 kind=INTERACTIVE
|
||||
err: thread 2 state=IDLE
|
||||
err: cleaning up
|
||||
END
|
||||
|
||||
PLANNED "error cleared on join"
|
||||
|
|
|
|||
|
|
@ -30,18 +30,18 @@
|
|||
|
||||
void is_prime(void * arg)
|
||||
{
|
||||
int number = *(int *)arg;
|
||||
int prime = 1;
|
||||
unsigned long long number = *(unsigned long long *)arg;
|
||||
unsigned long long prime = 1;
|
||||
|
||||
for (int x = number; x >= sqrt(number); --x)
|
||||
for (unsigned long long x = number-1; x >= sqrt(number); --x)
|
||||
{
|
||||
if (number % x == 0)
|
||||
if ((number % x) == 0)
|
||||
{
|
||||
prime = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*(int *)arg = prime;
|
||||
*(unsigned long long *)arg = prime;
|
||||
}
|
||||
|
||||
TESTS_BEGIN
|
||||
|
|
@ -66,7 +66,7 @@ TEST ("threadpool1")
|
|||
}
|
||||
|
||||
|
||||
TEST ("basic-acquire-release")
|
||||
TEST ("two-thread-acquire")
|
||||
{
|
||||
ECHO("start by initializing the threadpool");
|
||||
lumiera_threadpool_init();
|
||||
|
|
@ -90,13 +90,7 @@ TEST ("basic-acquire-release")
|
|||
ECHO("thread 2 state=%s", lumiera_threadstate_names[t2->state]);
|
||||
CHECK(LUMIERA_THREADSTATE_IDLE == t2->state);
|
||||
|
||||
ECHO("releasing thread 1");
|
||||
//lumiera_threadpool_release_thread(t1);
|
||||
ECHO("thread 1 has been released");
|
||||
|
||||
ECHO("releasing thread 2");
|
||||
//lumiera_threadpool_release_thread(t2);
|
||||
ECHO("thread 2 has been released");
|
||||
ECHO("cleaning up");
|
||||
|
||||
lumiera_threadpool_destroy();
|
||||
}
|
||||
|
|
@ -180,11 +174,11 @@ TEST ("process-function")
|
|||
{
|
||||
// this is what the scheduler would do once it figures out what function a job needs to run
|
||||
LumieraThread t;
|
||||
int number = 1073676287;
|
||||
unsigned long long number = 10000019;
|
||||
|
||||
lumiera_threadpool_init();
|
||||
|
||||
ECHO ("the input to the function is %d", number);
|
||||
ECHO ("the input to the function is %llu", number);
|
||||
|
||||
t = lumiera_thread_run (LUMIERA_THREADCLASS_INTERACTIVE,
|
||||
&is_prime,
|
||||
|
|
@ -193,8 +187,9 @@ TEST ("process-function")
|
|||
&NOBUG_FLAG(NOBUG_ON)); // struct nobug_flag* flag)
|
||||
|
||||
// cleanup
|
||||
ECHO("finished waiting");
|
||||
lumiera_threadpool_destroy();
|
||||
ECHO("the result is %llu", number);
|
||||
|
||||
}
|
||||
|
||||
TESTS_END
|
||||
|
|
|
|||
Loading…
Reference in a new issue