1.1 --- a/tests/dstest_exec.cc Mon Jun 13 00:43:15 2022 +0200
1.2 +++ b/tests/dstest_exec.cc Mon Jun 13 00:58:21 2022 +0200
1.3 @@ -40,6 +40,30 @@
1.4
1.5 static ExternalPager exec_pager;
1.6
1.7 +static const offset_t initial_stack_size = 16 * L4_PAGESIZE;
1.8 +
1.9 +
1.10 +
1.11 +/* Start the system pager in a separate thread. */
1.12 +
1.13 +static long start_pager(ipc_server_config_type &config)
1.14 +{
1.15 + pthread_t pager_thread;
1.16 + pthread_attr_t attr;
1.17 +
1.18 + pthread_attr_init(&attr);
1.19 + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
1.20 +
1.21 + ipc_server_init_for(&config, PagerObject, &exec_pager);
1.22 +
1.23 + long err = pthread_create(&pager_thread, &attr, ipc_server_start_mainloop, &config);
1.24 +
1.25 + if (err)
1.26 + return err;
1.27 +
1.28 + return ipc_server_start_config_thread(&config, pthread_l4_cap(pager_thread));
1.29 +}
1.30 +
1.31
1.32
1.33 int main(int argc, char *argv[])
1.34 @@ -54,7 +78,6 @@
1.35
1.36 /* Initialise the memory of the new task. */
1.37
1.38 - offset_t initial_stack_size = 16 * L4_PAGESIZE;
1.39 ExplicitSegment stack(Utcb_area_start - initial_stack_size, initial_stack_size, L4_FPAGE_RW);
1.40 Payload *payload;
1.41
1.42 @@ -80,27 +103,13 @@
1.43
1.44 exec_pager.add(stack.region());
1.45
1.46 - /* Start the pager. */
1.47 -
1.48 - pthread_t pager_thread;
1.49 - pthread_attr_t attr;
1.50 -
1.51 - pthread_attr_init(&attr);
1.52 - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
1.53 + /* Start the pager in a separate thread. */
1.54
1.55 ipc_server_config_type config;
1.56 - ipc_server_init_for(&config, PagerObject, &exec_pager);
1.57 -
1.58 - err = pthread_create(&pager_thread, &attr, ipc_server_start_mainloop, &config);
1.59 -
1.60 - if (err)
1.61 - {
1.62 - printf("Could not start pager thread.\n");
1.63 - return 1;
1.64 - }
1.65
1.66 printf("Starting pager thread...\n");
1.67 - err = ipc_server_start_config_thread(&config, pthread_l4_cap(pager_thread));
1.68 +
1.69 + err = start_pager(config);
1.70
1.71 if (err)
1.72 {
1.73 @@ -131,19 +140,19 @@
1.74
1.75 /* Populate a thread stack with argument and environment details. */
1.76
1.77 - Stack st(stack);
1.78 + Stack program_st(stack);
1.79
1.80 /* NOTE: Environment vector is currently not defined. */
1.81
1.82 char *envp[] = {NULL};
1.83
1.84 - st.populate(argc - 1, argv + 1, envp);
1.85 + program_st.populate(argc - 1, argv + 1, envp);
1.86
1.87 /* Start the new thread in the given stack. */
1.88
1.89 printf("Run thread...\n");
1.90
1.91 - err = process.thread_start(payload->entry_point(), st);
1.92 + err = process.thread_start(payload->entry_point(), program_st);
1.93
1.94 if (err)
1.95 {
1.96 @@ -152,7 +161,8 @@
1.97 }
1.98
1.99 printf("Finished.\n");
1.100 - while (1);
1.101 + while (1)
1.102 + l4_sleep_forever();
1.103
1.104 return 0;
1.105 }