2 extern int classsize[];
4 //NOTE: "pile" ptr points to the head of the linked list of the machine pile data structures
6 /* This function creates a new pile data structure to hold
7 * obj ids of objects modified or read inside a transaction,
8 * no of objects read and no of objects modified
9 * that belong to a single machine */
11 plistnode_t *pCreate(int objects) {
14 //Create main structure
15 if((pile = calloc(1, sizeof(plistnode_t))) == NULL) {
16 printf("Calloc error %s %d\n", __FILE__, __LINE__);
19 if ((pile->oidmod = calloc(objects, sizeof(unsigned int))) == NULL) {
20 printf("Calloc error %s %d\n", __FILE__, __LINE__);
25 if ((pile->oidread = calloc(objects, sizeof(unsigned int))) == NULL) {
26 printf("Calloc error %s %d\n", __FILE__, __LINE__);
30 if ((pile->objread = calloc(objects, sizeof(unsigned int) + sizeof(short))) == NULL) {
31 printf("Calloc error %s %d\n", __FILE__, __LINE__);
37 pile->nummod = pile->numread = pile->sum_bytes = 0;
42 /* This function inserts necessary information into
43 * a machine pile data structure */
44 plistnode_t *pInsert(plistnode_t *pile, objheader_t *headeraddr, unsigned int mid, int num_objs) {
45 plistnode_t *ptr, *tmp;
46 int found = 0, offset;
49 //Add oid into a machine that is already present in the pile linked list structure
51 if (tmp->mid == mid) {
52 if (STATUS(headeraddr) & DIRTY) {
53 tmp->oidmod[tmp->nummod] = OID(headeraddr);
54 tmp->nummod = tmp->nummod + 1;
55 tmp->sum_bytes += sizeof(objheader_t) + classsize[TYPE(headeraddr)];
57 // tmp->oidread[tmp->numread] = OID(headeraddr);
58 offset = (sizeof(unsigned int) + sizeof(short)) * tmp->numread;
59 *((unsigned int *)(tmp->objread + offset))=OID(headeraddr);
60 offset += sizeof(unsigned int);
61 memcpy(tmp->objread + offset, &headeraddr->version, sizeof(short));
62 tmp->numread = tmp->numread + 1;
69 //Add oid for any new machine
71 if((ptr = pCreate(num_objs)) == NULL) {
75 if (STATUS(headeraddr) & DIRTY) {
76 ptr->oidmod[ptr->nummod] = OID(headeraddr);
77 ptr->nummod = ptr->nummod + 1;
78 ptr->sum_bytes += sizeof(objheader_t) + classsize[TYPE(headeraddr)];
80 // ptr->oidread[ptr->numread] = OID(headeraddr);
81 *((unsigned int *)ptr->objread)=OID(headeraddr);
82 memcpy(ptr->objread + sizeof(unsigned int), &headeraddr->version, sizeof(short));
83 ptr->numread = ptr->numread + 1;
92 //Count the number of machine piles
93 int pCount(plistnode_t *pile) {
104 //Make a list of mid's for each machine group
105 int pListMid(plistnode_t *pile, unsigned int *list) {
109 while (tmp != NULL) {
117 //Delete the entire pile
118 void pDelete(plistnode_t *pile) {
119 plistnode_t *next, *tmp;
124 //free(tmp->oidread);