diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-08-30 19:20:21 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-08-30 19:20:21 +0300 |
| commit | 314bca3dc19a864c76153bfcd5a58be8c40000f9 (patch) | |
| tree | 9aba30284fce66e149a7472adea1cb4037e49463 /tests/shmem | |
| parent | 1a2e1fff7ce4b8fd8db46549d81e71e76b842da3 (diff) | |
| download | kmi-314bca3dc19a864c76153bfcd5a58be8c40000f9.tar.gz kmi-314bca3dc19a864c76153bfcd5a58be8c40000f9.zip | |
improvements to shared memory handling
+ Now each shared region is reference counter (technically each region
is refernce counted, private regions just have a count of 1).
Also, syscalls that touch the TLB get flushed, but should probably
look into where else this flushing might be needed.
Diffstat (limited to 'tests/shmem')
| -rw-r--r-- | tests/shmem/init.c | 36 | ||||
| -rw-r--r-- | tests/shmem/source.mk | 2 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/shmem/init.c b/tests/shmem/init.c new file mode 100644 index 0000000..13e1667 --- /dev/null +++ b/tests/shmem/init.c @@ -0,0 +1,36 @@ +#include <common/test.h> + +START(pid, tid, d0, d1, d2, d3) +{ + UNUSED(pid); + UNUSED(tid); + UNUSED(d0); + UNUSED(d1); + UNUSED(d2); + UNUSED(d3); + + printf("allocating shared memory\n"); + volatile char *shmem = sys_req_sharedmem(1, VM_R | VM_W); + check(shmem, "no shared memory?\n"); + + *shmem = 'p'; + + printf("sharing memory to ourselves\n"); + volatile char *refmem = sys_ref_sharedmem(1, (uintptr_t)shmem, VM_R | VM_W); + check(refmem[0] == 'p', "wrong mapping?\n"); + + printf("freeing shared memory (should fail)\n"); + enum sys_status r = sys_free_mem((uintptr_t)shmem); + check(r != OK, "illegal freeing succeeded?\n"); + + printf("freeing referenced memory\n"); + r = sys_free_mem((uintptr_t)refmem); + check(r == OK, "legal ref freeing failed?\n"); + check(shmem[0] == 'p', "freeing ref freed owned memory?\n"); + + printf("freeing recently nonshared memory\n"); + r = sys_free_mem((uintptr_t)shmem); + check(r == OK, "legal freeing failed?\n"); + + ok(); +} diff --git a/tests/shmem/source.mk b/tests/shmem/source.mk new file mode 100644 index 0000000..da84808 --- /dev/null +++ b/tests/shmem/source.mk @@ -0,0 +1,2 @@ +DO != ./scripts/gen-prog -n shmem -p init init.c +DO != ./scripts/gen-simple -n shmem -p init |
