Implemented killing a process + test
This commit is contained in:
parent
efa60d03b8
commit
0e3c365e4d
@ -5,6 +5,6 @@
|
|||||||
bootdriver /armv8/sbin/boot_armv8_generic
|
bootdriver /armv8/sbin/boot_armv8_generic
|
||||||
cpudriver /armv8/sbin/cpu_a57_qemu loglevel=3 serial=0x9000000 logmask=128
|
cpudriver /armv8/sbin/cpu_a57_qemu loglevel=3 serial=0x9000000 logmask=128
|
||||||
module /armv8/sbin/init
|
module /armv8/sbin/init
|
||||||
module /armv8/sbin/hello argument1 argument2 argument3
|
module /armv8/sbin/hello catch Aurel Jan Sandro
|
||||||
|
|
||||||
# End of file, this needs to have a certain length...
|
# End of file, this needs to have a certain length...
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
struct spawninfo {
|
struct spawninfo {
|
||||||
// the next in the list of spawned domains
|
// the next in the list of spawned domains
|
||||||
struct spawninfo *next;
|
struct spawninfo *next;
|
||||||
|
struct capref dispatcher; // < dispatcher used to start/stop the child process
|
||||||
|
|
||||||
// Information about the binary
|
// Information about the binary
|
||||||
char * binary_name; // Name of the binary
|
char * binary_name; // Name of the binary
|
||||||
|
|||||||
@ -82,7 +82,19 @@ handle_dispatcher_setup(
|
|||||||
return sys_dispatcher_setup(to, root, level, vptr, dptr, run, odptr);
|
return sys_dispatcher_setup(to, root, level, vptr, dptr, run, odptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct sysret
|
||||||
|
handle_dispatcher_stop(
|
||||||
|
struct capability* to,
|
||||||
|
arch_registers_state_t* context,
|
||||||
|
int argc
|
||||||
|
)
|
||||||
|
{
|
||||||
|
assert(argc == 2);
|
||||||
|
|
||||||
|
scheduler_remove(to->u.dispatcher.dcb);
|
||||||
|
|
||||||
|
return SYSRET(SYS_ERR_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct sysret
|
static struct sysret
|
||||||
@ -940,6 +952,7 @@ typedef struct sysret (*invocation_t)(struct capability*,
|
|||||||
static invocation_t invocations[ObjType_Num][CAP_MAX_CMD] = {
|
static invocation_t invocations[ObjType_Num][CAP_MAX_CMD] = {
|
||||||
[ObjType_Dispatcher] = {
|
[ObjType_Dispatcher] = {
|
||||||
[DispatcherCmd_Setup] = handle_dispatcher_setup,
|
[DispatcherCmd_Setup] = handle_dispatcher_setup,
|
||||||
|
[DispatcherCmd_Stop] = handle_dispatcher_stop,
|
||||||
[DispatcherCmd_Properties] = handle_dispatcher_properties,
|
[DispatcherCmd_Properties] = handle_dispatcher_properties,
|
||||||
[DispatcherCmd_PerfMon] = handle_dispatcher_perfmon,
|
[DispatcherCmd_PerfMon] = handle_dispatcher_perfmon,
|
||||||
[DispatcherCmd_DumpPTables] = dispatcher_dump_ptables,
|
[DispatcherCmd_DumpPTables] = dispatcher_dump_ptables,
|
||||||
|
|||||||
@ -10,6 +10,14 @@ void do_test_spawn(void) {
|
|||||||
struct spawninfo si[PROCESS_COUNT];
|
struct spawninfo si[PROCESS_COUNT];
|
||||||
domainid_t pid[PROCESS_COUNT];
|
domainid_t pid[PROCESS_COUNT];
|
||||||
for(uint i = 0; i < PROCESS_COUNT; ++i) {
|
for(uint i = 0; i < PROCESS_COUNT; ++i) {
|
||||||
|
debug_printf("TEST_SPAWN: spawn %u\n", i);
|
||||||
CHECK_ERR(spawn_load_by_name("hello", &(si[i]), &(pid[i])));
|
CHECK_ERR(spawn_load_by_name("hello", &(si[i]), &(pid[i])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(volatile int j = 0; j < 300000000; ++j);
|
||||||
|
|
||||||
|
for(uint i = 0; i < PROCESS_COUNT; ++i) {
|
||||||
|
debug_printf("TEST_SPAWN: Killing %u\n", i);
|
||||||
|
CHECK_ERR(invoke_dispatcher_stop(si[i].dispatcher));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -207,14 +207,13 @@ errval_t spawn_load_argv(int argc, char *argv[], struct spawninfo *si,
|
|||||||
if (err_is_fail(err)) return err;
|
if (err_is_fail(err)) return err;
|
||||||
|
|
||||||
// afeer: populate some capabilities
|
// afeer: populate some capabilities
|
||||||
struct capref dispatcher;
|
err = slot_alloc(&si->dispatcher);
|
||||||
err = slot_alloc(&dispatcher);
|
|
||||||
if (err_is_fail(err)) return err_push(err, LIB_ERR_SLOT_ALLOC);
|
if (err_is_fail(err)) return err_push(err, LIB_ERR_SLOT_ALLOC);
|
||||||
|
|
||||||
err = dispatcher_create(dispatcher);
|
err = dispatcher_create(si->dispatcher);
|
||||||
if (err_is_fail(err)) return err;
|
if (err_is_fail(err)) return err;
|
||||||
|
|
||||||
err = cap_copy(si->cspace_cap_dispatcher, dispatcher);
|
err = cap_copy(si->cspace_cap_dispatcher, si->dispatcher);
|
||||||
if (err_is_fail(err)) return err_push(err, LIB_ERR_CAP_COPY_FAIL);
|
if (err_is_fail(err)) return err_push(err, LIB_ERR_CAP_COPY_FAIL);
|
||||||
|
|
||||||
err = cap_retype(si->cspace_cap_selfep, si->cspace_cap_dispatcher, 0, ObjType_EndPointLMP, 0, 1);
|
err = cap_retype(si->cspace_cap_selfep, si->cspace_cap_dispatcher, 0, ObjType_EndPointLMP, 0, 1);
|
||||||
@ -356,7 +355,7 @@ errval_t spawn_load_argv(int argc, char *argv[], struct spawninfo *si,
|
|||||||
|
|
||||||
// - Make the new dispatcher runnable
|
// - Make the new dispatcher runnable
|
||||||
err = invoke_dispatcher(
|
err = invoke_dispatcher(
|
||||||
dispatcher, cap_dispatcher,
|
si->dispatcher, cap_dispatcher,
|
||||||
si->cspace_l1_cnode_cap, si->vspace_cap_l0_pagetable,
|
si->cspace_l1_cnode_cap, si->vspace_cap_l0_pagetable,
|
||||||
si->cspace_cap_dispframe, true
|
si->cspace_cap_dispframe, true
|
||||||
);
|
);
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <aos/aos.h>
|
#include <aos/aos.h>
|
||||||
|
|
||||||
@ -23,7 +24,12 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
printf("Hello, world!\n");
|
struct timespec tt;
|
||||||
|
|
||||||
|
if (clock_gettime(CLOCK_REALTIME, &tt) < 0) return 1;
|
||||||
|
double time = tt.tv_sec + tt.tv_nsec / 1000000000.0;\
|
||||||
|
|
||||||
|
printf("Hello, world! I am %lfs\n", time);
|
||||||
|
|
||||||
printf("argv:\n");
|
printf("argv:\n");
|
||||||
for(int i = 0; i < argc; ++i) {
|
for(int i = 0; i < argc; ++i) {
|
||||||
@ -33,9 +39,9 @@ int main(int argc, char *argv[])
|
|||||||
// if we receive the catch command, RUN!
|
// if we receive the catch command, RUN!
|
||||||
if (argc > 1 && !strncmp(argv[1], HELLO_CATCH_COMMAND, sizeof(HELLO_CATCH_COMMAND))) {
|
if (argc > 1 && !strncmp(argv[1], HELLO_CATCH_COMMAND, sizeof(HELLO_CATCH_COMMAND))) {
|
||||||
while(1) {
|
while(1) {
|
||||||
printf("Catch me if you can!\n");
|
printf("Catch %lf if you can!\n", time);
|
||||||
// wait a bit
|
// wait for 1 second
|
||||||
for(volatile int j = 0; j < 500000000; ++j);
|
for(volatile int j = 0; j < 50000000; ++j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user