uti: futex call function in mcctrl
Previously, futex code of McKerenl was called by mccontrol, but there ware some problems with this method. (Mainly, location of McKernel image on memory) Call futex code in mcctrl instead of the one in McKernel image, giving the following benefits: 1. Not relying on shared kernel virtual address space with Linux any more 2. The cpu id store / retrieve is not needed and resulting in the code Change-Id: Ic40929b64a655b270c435859fa287fedb713ee5c refe: #1428
This commit is contained in:
committed by
Masamichi Takagi
parent
35296c8210
commit
a9973e913d
@@ -25,17 +25,20 @@ pthread_t thr;
|
||||
long t_cond_wait, t_fwq;
|
||||
long nloop;
|
||||
long blocktime = 10L * 1000 * 1000;
|
||||
int linux_run;
|
||||
|
||||
void *util_fn(void *arg)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
long start, end;
|
||||
|
||||
print_cpu_last_executed_on("Utility thread");
|
||||
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret == -1, "Utility thread is running on Linux\n");
|
||||
}
|
||||
|
||||
pthread_barrier_wait(&bar);
|
||||
for (i = 0; i < nloop; i++) {
|
||||
@@ -50,7 +53,6 @@ void *util_fn(void *arg)
|
||||
flag = 1;
|
||||
pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
}
|
||||
|
||||
fn_fail:
|
||||
@@ -66,21 +68,24 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ret;
|
||||
long start, end;
|
||||
long start, end;
|
||||
cpu_set_t cpuset;
|
||||
pthread_attr_t attr;
|
||||
pthread_barrierattr_t bar_attr;
|
||||
struct sched_param param = { .sched_priority = 99 };
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "+b:", options, NULL)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "+b:l", options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
case 'b':
|
||||
blocktime = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
linux_run = 1;
|
||||
break;
|
||||
default: /* '?' */
|
||||
printf("unknown option %c\n", optopt);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
nloop = (10 * 1000000000UL) / blocktime;
|
||||
@@ -103,11 +108,13 @@ int main(int argc, char **argv)
|
||||
pthread_barrierattr_init(&bar_attr);
|
||||
pthread_barrier_init(&bar, &bar_attr, 2);
|
||||
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
if (!linux_run) {
|
||||
ret = syscall(732);
|
||||
OKNGNOJUMP(ret != -1, "Master thread is running on McKernel\n");
|
||||
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
ret = syscall(731, 1, NULL);
|
||||
OKNGNOJUMP(ret != -1, "util_indicate_clone\n");
|
||||
}
|
||||
|
||||
if ((ret = pthread_attr_init(&attr))) {
|
||||
printf("%s: Error: pthread_attr_init failed (%d)\n", __FUNCTION__, ret);
|
||||
@@ -128,11 +135,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if ((ret = sched_setscheduler(0, SCHED_FIFO, ¶m))) {
|
||||
fprintf(stderr, "Error: sched_setscheduler failed (%d)\n", ret);
|
||||
goto fn_fail;
|
||||
fprintf(stderr, "Warning: sched_setscheduler: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
syscall(701, 1 | 2);
|
||||
if (!linux_run) {
|
||||
syscall(701, 1 | 2);
|
||||
}
|
||||
pthread_barrier_wait(&bar);
|
||||
for (i = 0; i < nloop; i++) {
|
||||
start = rdtsc_light();
|
||||
@@ -147,7 +156,9 @@ int main(int argc, char **argv)
|
||||
end = rdtsc_light();
|
||||
t_cond_wait += end - start;
|
||||
}
|
||||
syscall(701, 4 | 8);
|
||||
if (!linux_run) {
|
||||
syscall(701, 4 | 8);
|
||||
}
|
||||
|
||||
pthread_join(thr, NULL);
|
||||
printf("[INFO] waker: %ld cycles, waiter: %ld cycles, (waiter - waker) / nloop: %ld cycles\n", t_fwq, t_cond_wait, (t_cond_wait - t_fwq) / nloop);
|
||||
|
||||
Reference in New Issue
Block a user