Remove the protected memory code associated with sensornet checkpointing because this functionality has been removed from Contiki.

This commit is contained in:
Nicolas Tsiftes 2016-04-20 12:47:37 +02:00
parent 204dcb9bbc
commit 7f700c9564

View file

@ -201,21 +201,13 @@ struct log_param {
}; };
/* /*
* The protected memory consists of structures that should not be * Variables that keep track of opened files and internal
* overwritten during system checkpointing because they may be used by * optimization information for Coffee.
* the checkpointing implementation. These structures need not be
* protected if checkpointing is not used.
*/ */
static struct protected_mem_t { static struct file coffee_files[COFFEE_MAX_OPEN_FILES];
struct file coffee_files[COFFEE_MAX_OPEN_FILES]; static struct file_desc coffee_fd_set[COFFEE_FD_SET_SIZE];
struct file_desc coffee_fd_set[COFFEE_FD_SET_SIZE]; static coffee_page_t next_free;
coffee_page_t next_free; static char gc_wait;
char gc_wait;
} protected_mem;
static struct file *const coffee_files = protected_mem.coffee_files;
static struct file_desc *const coffee_fd_set = protected_mem.coffee_fd_set;
static coffee_page_t *const next_free = &protected_mem.next_free;
static char *const gc_wait = &protected_mem.gc_wait;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
@ -387,8 +379,8 @@ collect_garbage(int mode)
if((mode == GC_RELUCTANT && stats.free == 0) || if((mode == GC_RELUCTANT && stats.free == 0) ||
(mode == GC_GREEDY && stats.obsolete > 0)) { (mode == GC_GREEDY && stats.obsolete > 0)) {
first_page = sector * COFFEE_PAGES_PER_SECTOR; first_page = sector * COFFEE_PAGES_PER_SECTOR;
if(first_page < *next_free) { if(first_page < next_free) {
*next_free = first_page; next_free = first_page;
} }
if(isolation_count > 0) { if(isolation_count > 0) {
@ -539,7 +531,7 @@ find_contiguous_pages(coffee_page_t amount)
struct file_header hdr; struct file_header hdr;
start = INVALID_PAGE; start = INVALID_PAGE;
for(page = *next_free; page < COFFEE_PAGE_COUNT;) { for(page = next_free; page < COFFEE_PAGE_COUNT;) {
read_header(&hdr, page); read_header(&hdr, page);
if(HDR_FREE(hdr)) { if(HDR_FREE(hdr)) {
if(start == INVALID_PAGE) { if(start == INVALID_PAGE) {
@ -555,8 +547,8 @@ find_contiguous_pages(coffee_page_t amount)
page = next_file(page, &hdr); page = next_file(page, &hdr);
if(start + amount <= page) { if(start + amount <= page) {
if(start == *next_free) { if(start == next_free) {
*next_free = start + amount; next_free = start + amount;
} }
return start; return start;
} }
@ -589,7 +581,7 @@ remove_by_page(coffee_page_t page, int remove_log, int close_fds,
hdr.flags |= HDR_FLAG_OBSOLETE; hdr.flags |= HDR_FLAG_OBSOLETE;
write_header(&hdr, page); write_header(&hdr, page);
*gc_wait = 0; gc_wait = 0;
/* Close all file descriptors that reference the removed file. */ /* Close all file descriptors that reference the removed file. */
if(close_fds) { if(close_fds) {
@ -638,13 +630,13 @@ reserve(const char *name, coffee_page_t pages,
page = find_contiguous_pages(pages); page = find_contiguous_pages(pages);
if(page == INVALID_PAGE) { if(page == INVALID_PAGE) {
if(*gc_wait) { if(gc_wait) {
return NULL; return NULL;
} }
collect_garbage(GC_GREEDY); collect_garbage(GC_GREEDY);
page = find_contiguous_pages(pages); page = find_contiguous_pages(pages);
if(page == INVALID_PAGE) { if(page == INVALID_PAGE) {
*gc_wait = 1; gc_wait = 1;
return NULL; return NULL;
} }
} }
@ -1346,24 +1338,19 @@ cfs_coffee_format(void)
PRINTF("Coffee: Formatting %u sectors", COFFEE_SECTOR_COUNT); PRINTF("Coffee: Formatting %u sectors", COFFEE_SECTOR_COUNT);
*next_free = 0;
for(i = 0; i < COFFEE_SECTOR_COUNT; i++) { for(i = 0; i < COFFEE_SECTOR_COUNT; i++) {
COFFEE_ERASE(i); COFFEE_ERASE(i);
PRINTF("."); PRINTF(".");
} }
/* Formatting invalidates the file information. */ /* Formatting invalidates the file information. */
memset(&protected_mem, 0, sizeof(protected_mem)); memset(&coffee_files, 0, sizeof(coffee_files));
memset(&coffee_fd_set, 0, sizeof(coffee_fd_set));
next_free = 0;
gc_wait = 1;
PRINTF(" done!\n"); PRINTF(" done!\n");
return 0; return 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void *
cfs_coffee_get_protected_mem(unsigned *size)
{
*size = sizeof(protected_mem);
return &protected_mem;
}