Post Scarcity
A prototype for a post scarcity programming environment
Loading...
Searching...
No Matches
conspage.h
Go to the documentation of this file.
1/*
2 * conspage.h
3 *
4 * Setup and tear down cons pages, and (FOR NOW) do primitive
5 * allocation/deallocation of cells.
6 * NOTE THAT before we go multi-threaded, these functions must be
7 * aggressively
8 * thread safe.
9 *
10 * (c) 2017 Simon Brooke <simon@journeyman.cc>
11 * Licensed under GPL version 2.0, or, at your option, any later version.
12 */
13#ifndef __psse_conspage_h
14#define __psse_conspage_h
15
17
18/**
19 * the number of cons cells on a cons page. The maximum value this can
20 * be (and consequently, the size which, by version 1, it will default
21 * to) is the maximum value of an unsigned 32 bit integer, which is to
22 * say 4294967296. However, we'll start small.
23 */
24#define CONSPAGESIZE 1024
25
26/**
27 * the number of cons pages we will initially allow for. For
28 * convenience we'll set up an array of cons pages this big; however,
29 * later we will want a mechanism for this to be able to grow
30 * dynamically to the maximum we can currently allow, which is
31 * 4294967296.
32 *
33 * Note that this means the total number of addressable cons cells is
34 * 1.8e19, each of 20 bytes; or 3e20 bytes in total; and there are
35 * up to a maximum of 4e9 of heap space objects, each of potentially
36 * 4e9 bytes. So we're talking about a potential total of 8e100 bytes
37 * of addressable memory, which is only slightly more than the
38 * number of atoms in the universe.
39 */
40#define NCONSPAGES 64
41
42/**
43 * a cons page is essentially just an array of cons space objects. It
44 * might later have a local free list (i.e. list of free cells on this
45 * page) and a pointer to the next cons page, but my current view is
46 * that that's probably unneccessary.
47 */
51
52extern struct cons_pointer freelist;
53
54extern struct cons_page *conspages[NCONSPAGES];
55
56void free_cell( struct cons_pointer pointer );
57
58struct cons_pointer allocate_cell( uint32_t tag );
59
61
62void dump_pages( URL_FILE * output );
63
65
66#endif
struct cons_pointer allocate_cell(uint32_t tag)
Allocates a cell with the specified tag.
Definition conspage.c:222
#define NCONSPAGES
the number of cons pages we will initially allow for.
Definition conspage.h:40
#define CONSPAGESIZE
the number of cons cells on a cons page.
Definition conspage.h:24
struct cons_page * conspages[NCONSPAGES]
An array of pointers to cons pages.
Definition conspage.c:51
void free_cell(struct cons_pointer pointer)
Frees the cell at the specified pointer; for all the types of cons-space object which point to other ...
Definition conspage.c:143
void dump_pages(URL_FILE *output)
dump the allocated pages to this output stream.
Definition conspage.c:124
struct cons_space_object cell[CONSPAGESIZE]
Definition conspage.h:49
void summarise_allocation()
Definition conspage.c:271
struct cons_pointer freelist
The (global) pointer to the (global) freelist.
Definition conspage.c:46
void initialise_cons_pages()
initialise the cons page system; to be called exactly once during startup.
Definition conspage.c:257
a cons page is essentially just an array of cons space objects.
Definition conspage.h:48
An indirect pointer to a cons cell.
an object in cons space.