aboutsummaryrefslogtreecommitdiffstats
path: root/arena.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2001-10-26 01:58:29 +0000
committerH. Peter Anvin <hpa@zytor.com>2001-10-26 01:58:29 +0000
commit4bd929b8e7ca1b8b7d4b2479216eb9120b8b7350 (patch)
treed47d6232353ac73108753c753b124501a9702b9b /arena.c
parent9f4b121beb7c16b26f25a694ceba998d3d1a23c8 (diff)
downloadlpsm-4bd929b8e7ca1b8b7d4b2479216eb9120b8b7350.tar.gz
lpsm-4bd929b8e7ca1b8b7d4b2479216eb9120b8b7350.tar.xz
lpsm-4bd929b8e7ca1b8b7d4b2479216eb9120b8b7350.zip
Split up documentation further. Add lpsm_need_checkpoint local variable.
Diffstat (limited to 'arena.c')
-rw-r--r--arena.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/arena.c b/arena.c
index 6c5a1b0..335400c 100644
--- a/arena.c
+++ b/arena.c
@@ -47,6 +47,11 @@
*/
struct lpsm_arena *lpsm_memory_info = NULL;
+/*
+ * This variable is set when the persistent memory is dirty.
+ */
+sig_atomic_t lpsm_need_checkpoint;
+
/* Wrappers for read() and write() which retries if incomplete */
static ssize_t lpsm_read(int fd, void *buf, size_t count)
{
@@ -159,6 +164,7 @@ static void lpsm_sigsegv(int signal, siginfo_t *siginfo, void *ptr)
case page_clean:
*pageinfo = page_dirty; /* Page now dirty */
PM->dirty_count++; /* For accounting purposes */
+ lpsm_need_checkpoint = 1; /* For user programs */
/* Leave page r/w */
break;
@@ -407,6 +413,7 @@ void *lpsm_arena_init(const char *main_file, const char *log_file,
/* All pages clean at this time */
memset(PM->pageinfo, page_clean, len_pages);
+ lpsm_need_checkpoint = 0;
sigact.sa_sigaction = lpsm_sigsegv;
sigemptyset(&sigact.sa_mask);
@@ -512,6 +519,9 @@ pid_t lpsm_checkpoint(double gc_factor, enum psmsync wait)
}
}
+ if ( !lpsm_need_checkpoint )
+ return 0; /* If not dirty, don't fork */
+
f = fork();
if ( f == (pid_t)-1 )
return (pid_t)-1; /* Checkpoint failed! */
@@ -522,7 +532,8 @@ pid_t lpsm_checkpoint(double gc_factor, enum psmsync wait)
array for a while. */
mprotect(PM->arena, PM->arena_len, PROT_READ);
memset(PM->pageinfo, page_clean, PM->arena_len >> PM->pageshift);
-
+ lpsm_need_checkpoint = 0;
+
PM->dirty_count = 0; /* No pages dirty */
PM->fork_seq++; /* Increase next sequence number */