minor fix
This commit is contained in:
parent
046023f89d
commit
3cb6b6fabf
5
chbuild
5
chbuild
|
@ -211,9 +211,8 @@ _docker_run() {
|
|||
$@
|
||||
else
|
||||
test -t 1 && use_tty="-t"
|
||||
# docker run -i $use_tty --rm \
|
||||
# -u $(id -u ${USER}):$(id -g ${USER}) \
|
||||
docker run -it \
|
||||
docker run -i $use_tty --rm \
|
||||
-u $(id -u ${USER}):$(id -g ${USER}) \
|
||||
-v $(pwd):/chos -w /chos \
|
||||
promisivia/treesls_chcore_builder:v2.2 \
|
||||
$self $@
|
||||
|
|
|
@ -4,11 +4,11 @@ set(SLS_EXT_SYNC OFF)
|
|||
set(SLS_HYBRID_MEM ON)
|
||||
|
||||
# SLS Report Details
|
||||
set(SLS_REPORT_CKPT ON)
|
||||
set(SLS_REPORT_RESTORE ON)
|
||||
set(SLS_REPORT_HYBRID ON)
|
||||
set(SLS_REPORT_CKPT OFF)
|
||||
set(SLS_REPORT_RESTORE OFF)
|
||||
set(SLS_REPORT_HYBRID OFF)
|
||||
|
||||
# SLS special tests: for tests of only-checkpoint, +pf, +memcpy
|
||||
set(SLS_SPECIAL_OMIT_PF OFF)
|
||||
set(SLS_SPECIAL_OMIT_MEMCPY OFF)
|
||||
set(SLS_SPECIAL_OMIT_BENCHMARK ON)
|
||||
set(SLS_SPECIAL_OMIT_BENCHMARK OFF)
|
||||
|
|
|
@ -6,6 +6,10 @@ add_executable(idle.bin idle.c)
|
|||
# checkpoint
|
||||
add_executable(checkpoint.bin checkpoint.c)
|
||||
|
||||
# test applications
|
||||
add_executable(test_crash_hello.bin test_crash_hello.c)
|
||||
add_executable(test_crash_counter.bin test_crash_counter.c)
|
||||
|
||||
# adjust config
|
||||
add_executable(set_poll_loop_time.bin set_poll_loop_time.c)
|
||||
add_executable(set_dyn_hybrid_config.bin set_dyn_hybrid_config.c)
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
#include <chcore/syscall.h>
|
||||
#include <chcore/launcher.h>
|
||||
|
||||
#define LEADER 0
|
||||
#define FOLLOWER 1
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
const int sleep_every_step = TRUE;
|
||||
|
||||
struct shared_data {
|
||||
int turn;
|
||||
int counter;
|
||||
};
|
||||
|
||||
volatile struct shared_data *region;
|
||||
|
||||
void count(int myturn) {
|
||||
for (;;) {
|
||||
/* wait for my turn */
|
||||
while (region->turn != myturn);
|
||||
|
||||
/* output and add 1 */
|
||||
printf("%d: [%d]\n", myturn, region->counter++);
|
||||
|
||||
/* give it to the other process */
|
||||
region->turn ^= 1;
|
||||
|
||||
if (sleep_every_step) {
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void counter_leader(char *program) {
|
||||
/* create shared memory */
|
||||
int shmid = shmget(-1, sizeof(struct shared_data), IPC_CREAT);
|
||||
assert(shmid > 0);
|
||||
printf("created shared memory with id = %d\n", shmid);
|
||||
|
||||
/* map shared memory */
|
||||
region = (volatile struct shared_data *)shmat(shmid, 0, 0);
|
||||
assert((s64)region != -EINVAL);
|
||||
|
||||
/* initialize the shared structure */
|
||||
region->turn = 0; // leader
|
||||
region->counter = 1;
|
||||
|
||||
/* spawn the follower process */
|
||||
char *argv[] = { program, "follower" };
|
||||
chcore_new_process(sizeof(argv) / sizeof(*argv), argv, 0);
|
||||
|
||||
/* spawn ckpt process */
|
||||
/* TODO: only for simulating */
|
||||
char *argv2[] = {"checkpoint.bin"};
|
||||
chcore_new_process(sizeof(argv2) / sizeof(*argv2), argv2, 0);
|
||||
|
||||
/* start counting */
|
||||
count(LEADER);
|
||||
}
|
||||
|
||||
void counter_follower() {
|
||||
/* map shared memory */
|
||||
int shmid = shmget(-1, sizeof(struct shared_data), IPC_CREAT);
|
||||
region = (volatile struct shared_data *)shmat(shmid, 0, 0);
|
||||
assert((s64)region != -EINVAL);
|
||||
|
||||
/* start counting */
|
||||
count(FOLLOWER);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
switch (argc) {
|
||||
case 1:
|
||||
counter_leader(argv[0]);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
counter_follower();
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Please launch this program with 0 or 1 arguments!\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <chcore/type.h>
|
||||
#include <chcore/syscall.h>
|
||||
|
||||
int main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
int cnt = 0;
|
||||
|
||||
while (1) {
|
||||
printf("[%d] hello world\n", cnt);
|
||||
usys_whole_ckpt("test_crash_hello", 17);
|
||||
cnt++;
|
||||
sleep(1);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue