inline void startScheduling() { startTimer(TASK_SCHEDULING_TIMER_NO); __DEBUG("Scheduler Start! \r\n\n"); // infinity loop for scheduling while(1) { //Flag Check if(g_stMONLocalData.eCurrentBuffer_SampeType != LG_SAMPLE_NONE) { // include DSP Processing & ADC Control! // Must!!! finished in 33ms fpDSPHandler[g_stMONLocalData.eCurrentBuffer_SampeType](g_stMONLocalData.pSampleBaseAddress); continue; } //Other Job // DC/DC Check - 5, 8, 15, -15, 28, 50, 28_IN // CPLD Communicatoin - CRS, CLR, Differ Freq. // CAN // Debug Message selectSideJobs(); } // Do not reach this statement! __DEBUG("Scheduler End! \r\n"); }
void ConflictSet_insertLocalUpdate( ConflictSet *conflictSet, MethodCallObject *methodCallObject) { Generation *gen; /* Lock the structures */ pthread_mutex_lock( &conflictSet->writeLock ); __DEBUG( "Locking conflict set for local update" ); if( ConflictSet_isFull( conflictSet ) ) { __ERROR( "Conflict set is full!" ); exit( 1 ); } gen = ConflictSet_createNewGeneration( conflictSet ); /* Store local information about the generation */ gen->generationType[__conf.id] = GEN_UPDATE; gen->generationData[__conf.id].methodCallObject = methodCallObject; /* Tell the update what generation it has been stored in */ methodCallObject->generationNumber = gen->number; __DEBUG( "Added generation %d for method <%s>", gen->number, methodCallObject->methodName ); __DEBUG( "Unlocking conflict set for writing local update" ); /* Unlock the structure */ pthread_mutex_unlock( &conflictSet->writeLock ); }
uint64_t _read_offset(struct sst *sst, struct slice *sk) { int fd; int fcount; int blk_sizes; int result; uint64_t off = 0UL; char file[FILE_PATH_SIZE]; struct sst_block *blks; struct footer footer; int fsize = sizeof(struct footer); memset(file, 0, FILE_PATH_SIZE); snprintf(file, FILE_PATH_SIZE, "%s/%s", sst->basedir, sst->name); fd = open(file, O_RDWR, 0644); result = lseek(fd, -fsize, SEEK_END); if(result == -1) { abort(); } result = read(fd, &footer, fsize); if(result == -1) { abort(); } fcount = from_be32(footer.count); blk_sizes = fcount*sizeof(struct sst_block); blks = mmap(0, blk_sizes, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if(blks == MAP_FAILED) { __DEBUG(LEVEL_ERROR, "%s", "Error:read_offset, mmapping the file"); goto out; } size_t left = 0, right = fcount, i = 0; while(left < right) { i = (right - left) / 2 + left; int cmp = strcmp(sk->data, blks[i].key); if(cmp == 0) { off = from_be64(blks[i].offset); break; } if(cmp < 0) right = i; else left = i + 1; } if(munmap(blks, blk_sizes) == -1) __DEBUG(LEVEL_ERROR, "%s", "read_offset:un-mmapping the file"); out : close(fd); return off; }
void _sst_load(struct sst *sst) { int fd, result; int all_count = 0; DIR *dd; struct dirent *de;; dd = opendir(sst->basedir); while ((de = readdir(dd))) { if(strstr(de->d_name, ".sst")) { int fcount = 0, fcrc = 0; struct meta_node mn; struct footer footer; char sst_file[FILE_PATH_SIZE]; int fsize = sizeof(struct footer); memset(sst_file, 0, FILE_PATH_SIZE); snprintf(sst_file, FILE_PATH_SIZE, "%s/%s", sst->basedir, de->d_name); fd = open(sst_file, O_RDWR, 0644); lseek(fd, -fsize, SEEK_END); result = read(fd, &footer, sizeof(struct footer)); if(result == -1) abort(); fcount = from_be32(footer.count); fcrc = from_be32(footer.crc); if(fcrc != F_CRC) { __DEBUG(LEVEL_ERROR, "Error: crc wrong, crc:<%d>, index<%s>", fcrc, sst_file); close(fd); continue; } if(fcount == 0) { close(fd); continue; } all_count += fcount; mn.count = fcount; memset(mn.end, 0, NESSDB_MAX_KEY_SIZE); memcpy(mn.end, footer.key, NESSDB_MAX_KEY_SIZE); memset(mn.index_name, 0, FILE_NAME_SIZE); memcpy(mn.index_name, de->d_name, FILE_NAME_SIZE); meta_set(sst->meta, &mn); close(fd); } } closedir(dd); __DEBUG(LEVEL_DEBUG, "load sst, all entries count:<%d>", all_count); }
int handleCAN_ALL_UnitStatus_NoAck(CAN_DataNode stCANMessage) { __DEBUG("Receive ALL Unit Status(No ACK)\r\n\n"); // CAN Message Process if(stCANMessage.uLength < 3) { // Must Exception Handling __DEBUG("Unit Status(No ACK) RECEIVE ERROR\r\n\n"); return -1; } g_stMONLocalData.uOtherUnitPDStatus = *((uint16_t*)&stCANMessage.uData[0]); g_stMONLocalData.uOtherUnitFaultStatus = stCANMessage.uData[2]; return 0; }
void ConflictSet_notifyPropagation( ConflictSet *conflictSet ) { int generationPosition, currentGenPos; MethodCallObject *methodCallObject; GSList *methodCalls; methodCalls = NULL; /* Check if no prior proagation has been performed */ if( conflictSet->propagatedGeneration == -1 ) { generationPosition = 0; } else if( conflictSet->propagatedGeneration >= conflictSet->maxGeneration ) { __DEBUG( "No need to propagate!" ); return; } else { /* Get the first generation that is not propagated */ generationPosition = ConflictSet_getGenerationPosition( conflictSet, conflictSet->propagatedGeneration + 1 ); if( generationPosition == -1 ) { __ERROR( "Failed to get generation position in notifyPropagation()" ); } } __DEBUG( "Starting to propagate from generation set with index: %d", generationPosition ); for( currentGenPos = generationPosition; currentGenPos <= conflictSet->maxPosition; currentGenPos = (currentGenPos + 1 ) % conflictSet->numberOfGenerations ) { methodCallObject = conflictSet->generations[ currentGenPos ].generationData[__conf.id].methodCallObject; methodCalls = g_slist_append( methodCalls, methodCallObject ); //propagate( methodCallObject, __conf.replicas, conflictSet->dboid ); conflictSet->propagatedGeneration = methodCallObject->generationNumber; __DEBUG( "Propagted generation %d for object with dboid %s", methodCallObject->generationNumber, methodCallObject->databaseObjectId ); } /* Sends all the updates to all nodes on the network */ propagateList( methodCalls, __conf.replicas, conflictSet->dboid ); __DEBUG( "Propagated generation %d", conflictSet->propagatedGeneration ); g_slist_free( methodCalls ); }
static void _root_split(struct tree *t, struct node *new_root, struct node *old_root) { LOG; struct node *a; struct node *b; struct msg *split_key = NULL; printf("root split begin, old NID %"PRIu64" , height %d" , old_root->nid , old_root->height); if (old_root->height > 0 || old_root->n_children > 2) _node_split(t, old_root, &a, &b, &split_key); else _leaf_and_lmb_split(t, old_root, &a, &b, &split_key); /* swap two roots */ _root_swap(new_root, old_root); msgcpy(&new_root->pivots[0], split_key); new_root->parts[0].child_nid = a->nid; new_root->parts[1].child_nid = b->nid; msgfree(split_key); cache_unpin(t->cf, b->cpair, make_cpair_attr(b)); node_set_dirty(old_root); node_set_dirty(new_root); t->hdr->height++; status_increment(&t->e->status->tree_root_new_nums); __DEBUG("root split end, old NID %"PRIu64, old_root->nid); }
int main() { int i,ret; char key[KSIZE]; char val[VSIZE]; struct slice sk,sv; struct index *idx=index_new("test_idx",MAX_MTBL,MAX_MTBL_SIZE); for(i=0;i < LOOP;i++){ snprintf(key,KSIZE,"key:%d",i); snprintf(val,VSIZE,"val:%d",i); sk.len=KSIZE; sk.data=key; sv.len=VSIZE; sv.data=val; ret=index_add(idx,&sk,&sv); if(!ret) __DEBUG("%s","Write failed...."); } return 0; }
int handleCAN_COM_getMCUUniqueID(CAN_DataNode stCANMessage) { CAN_DataNode stMessage = {{0}, g_stMONLocalData.uCANSendID, 0, 0}; __DEBUG("Receive get MCU Unique ID\r\n\n"); uint8_t *uID = (uint8_t *)0x1FFFF7E8; // CAN Message Send - Low ID stMessage.uOpcode = CAN_S_COM_OP_MCU_UNIQUE_ID; stMessage.uLength = 7; stMessage.uData[0] = LOW; stMessage.uData[1] = uID[0]; stMessage.uData[2] = uID[1]; stMessage.uData[3] = uID[2]; stMessage.uData[4] = uID[3]; stMessage.uData[5] = uID[4]; stMessage.uData[6] = uID[5]; addRear_Queue(&g_stCANSendQueue, (void *)&stMessage); // CAN Message Send - High ID stMessage.uOpcode = CAN_S_COM_OP_MCU_UNIQUE_ID; stMessage.uLength = 5; stMessage.uData[0] = LOW; stMessage.uData[1] = uID[6]; stMessage.uData[2] = uID[7]; stMessage.uData[3] = uID[8]; stMessage.uData[4] = uID[9]; stMessage.uData[5] = uID[10]; stMessage.uData[6] = uID[11]; addRear_Queue(&g_stCANSendQueue, (void *)&stMessage); return 0; }
void ConflictSet_notifyStabilization( ConflictSet *conflictSet, int endGeneration ) { int startGeneration; /* Check if stabilization has been performed before */ if( conflictSet->stabilizedGeneration == -1 ) { startGeneration = 0; } else { /* Get the first generation that haven't been stabilized */ startGeneration = conflictSet->stabilizedGeneration + 1; } /* Stabilize all generations that have been created * This insures that the maximum number of generations are send to the replicas */ //endGeneration = conflictSet->maxGeneration; /* Check that message is required */ if( startGeneration <= endGeneration ) { /* Sends the stabilization to all replicas */ sendStabilizationMessage( __conf.replicas, startGeneration, endGeneration, __conf.id, conflictSet->dboid ); /* Update what generations that have been send */ conflictSet->stabilizedGeneration = endGeneration; } __DEBUG( "Sended stabilization from gen %d to %d", startGeneration, endGeneration ); }
int handleCAN_ALL_UnitStatus(CAN_DataNode stCANMessage) { __DEBUG("Receive ALL Unit Status\r\n\n"); // CAN Message Process if(stCANMessage.uLength < 3) { // Must Exception Handling __DEBUG("Unit Status RECEIVE ERROR\r\n\n"); return -1; } g_stMONLocalData.uOtherUnitPDStatus = *((uint16_t*)&stCANMessage.uData[0]); g_stMONLocalData.uOtherUnitFaultStatus = stCANMessage.uData[2]; sendLiveMessagetoSCU(LIVEMODE_NORMAL); return 0; }
int networkSendAll( int socket, void *data, int length ) { int totalSent; int bytesLeft; int sent; totalSent = 0; bytesLeft = length; __DEBUG( "Sending %d bytes", length ); /* Sends some amount of data at the time until all is sent */ while( totalSent < length ) { sent = send( socket, data + totalSent, bytesLeft, 0); if( sent == -1 ) { __ERROR( "Failed to send %d bytes ", bytesLeft ); continue; } totalSent = totalSent + sent; bytesLeft = bytesLeft - sent; } return 1; }
int ConflictSet_getGenerationPosition( ConflictSet *conflictSet, int generation ) { int it; int generationPosition; // Check if generation number is out of bounds if( generation < conflictSet->minGeneration || generation > conflictSet->maxGeneration ) { return -1; } generationPosition = conflictSet->minPosition; for( it = conflictSet->minGeneration; it <= conflictSet->maxGeneration; ++it ) { if( it == generation ) { return generationPosition; } /* Increase the array pointer */ generationPosition = (generationPosition + 1) % conflictSet->numberOfGenerations; } __DEBUG("Failed in getGenerationPosition: min=%d,max=%d,gen=%d", conflictSet->minGeneration, conflictSet->maxGeneration, generation ); return -1; }
struct skiplist *_read_mmap(struct sst *sst, size_t count) { int i; int fd; int result; int fcount; int blk_sizes; char file[FILE_PATH_SIZE]; struct sst_block *blks; struct skiplist *merge = NULL; struct footer footer; int fsize = sizeof(struct footer); memset(file, 0, FILE_PATH_SIZE); snprintf(file, FILE_PATH_SIZE, "%s/%s", sst->basedir, sst->name); fd = open(file, O_RDWR, 0644); result = lseek(fd, -fsize, SEEK_END); if(result == -1) abort(); result = read(fd, &footer, fsize); if(result == -1) abort(); fcount = from_be32(footer.count); blk_sizes = fcount * sizeof(struct sst_block); blks = mmap(0, blk_sizes, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if(blks == MAP_FAILED) { __DEBUG(LEVEL_ERROR, "%s", "Error: sst_bloom un-mmapping the file"); goto out; } merge = skiplist_new(fcount + count + 1); for(i = 0; i < fcount; i++) { skiplist_insert(merge, blks[i].key, from_be64(blks[i].offset), ADD); } if(munmap(blks, blk_sizes) == -1) { __DEBUG(LEVEL_ERROR, "%s", "read_map:un-mmapping the file"); } out: close(fd); return merge; }
void networkSendDataToAll( GSList *replicas, void *data, int dataSize ) { GSList *it; int rep_socket; Replica *replica; /* * Create a connection to the replica * Send the package to the replica * Finally, close the connection */ for (it = replicas; it != NULL; it = g_slist_next( it ) ) { replica = it->data; /* Check if connection exists to the replica, otherwise create a new one */ if( replica->tcpSocket == -1 ) { /* Try to make a connection, if failure, wait 250ms */ while(1) { rep_socket = networkCreateTCPSocket( replica->host, replica->port ); if( rep_socket == -1 ) { __DEBUG( "Failed to connect to host %s on port %d", replica->host, replica->port ); usleep( 25000 ); } else { __DEBUG( "Connection successful to host %s on port %d", replica->host, replica->port ); break; } } replica->tcpSocket = rep_socket; } //__DEBUG( "Sending %lud bytes", sizeof( struct prop_package ) ); if( networkSendAll( replica->tcpSocket, data, dataSize ) == -1 ) { __ERROR( "Failed to send propagation data: %s", strerror( errno ) ); } /* We are done with this replica, close connection */ //close( rep_socket ); } }
////////////////////////////////////////////////////// // Can Receive Handler Function Define Section // ////////////////////////////////////////////////////// int handleCAN_ALL_BootComplete(CAN_DataNode stCANMessage) { __DEBUG("Receive Boot Complete - But No Job\r\n\n"); // Currently No Job // or // Send All Setting Value Send Message // TBD return 0; }
void _silopit_load(struct silopit *silopit) { int fd, result, all_count = 0; DIR *dd; struct dirent *de; dd = opendir(silopit->basedir); while ((de = readdir(dd))) { if (strstr(de->d_name, ".silopit")) { int fcount = 0, fcrc = 0; struct meta_node mn; struct footer footer; char silopit_file[FILE_PATH_SIZE]; int fsize = sizeof(struct footer); memset(silopit_file, 0, FILE_PATH_SIZE); snprintf(silopit_file, FILE_PATH_SIZE, "%s/%s", silopit->basedir, de->d_name); fd = open(silopit_file, O_RDWR, 0644); lseek(fd, -fsize, SEEK_END); result = read(fd, &footer, sizeof(struct footer)); if (result != sizeof(struct footer)) __PANIC("read footer error"); fcount = from_be32(footer.count); fcrc = from_be32(footer.crc); if (fcrc != F_CRC) { __PANIC("Crc wrong, silo file maybe broken, crc:<%d>,index<%s>", fcrc, silopit_file); close(fd); continue; } if (fcount == 0) { close(fd); continue; } _add_hiraishin(silopit, fd, fcount, from_be32(footer.max_len)); all_count += fcount; mn.count = fcount; memset(mn.end, 0, SILOKATANA_MAX_KEY_SIZE); memcpy(mn.end, footer.key, SILOKATANA_MAX_KEY_SIZE); memset(mn.index_name, 0, FILE_NAME_SIZE); memcpy(mn.index_name, de->d_name, FILE_NAME_SIZE); meta_set(silopit->meta, &mn); close(fd); } } closedir(dd); __DEBUG("Load silopit,all entries count:<%d>", all_count); }
int networkCreateTCPSocket( char *host, int port ) { int connectSocket, rv; struct addrinfo hints, *servinfo, *p; char port_str[10]; memset( &hints, 0, sizeof hints ); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; // use my IP snprintf( port_str, sizeof(port_str), "%d", port ); if ((rv = getaddrinfo( host, port_str, &hints, &servinfo)) != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); return -1; } // loop through all the results and bind to the first we can for(p = servinfo; p != NULL; p = p->ai_next) { if ((connectSocket = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) { perror("server: socket"); continue; } /* if (setsockopt(listenSocket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) { perror("setsockopt"); exit(1); } */ if (connect( connectSocket, p->ai_addr, p->ai_addrlen) == -1) { close( connectSocket ); __DEBUG( "network_create_tcp_socket: %s", strerror(errno)); continue; } break; } if( p == NULL ) { return -1; } freeaddrinfo(servinfo); // all done with this structure return connectSocket; }
void _readone_test(char *key) { int ret; struct slice sk; struct slice sv; struct index *idx; idx = _get_idx(); sk.len = KSIZE; sk.data = key; ret = index_get(idx, &sk, &sv); if (ret) { __DEBUG(LEVEL_INFO, "Get Key:<%s>--->value is :<%s>", key, sv.data); free(sv.data); } else __DEBUG(LEVEL_INFO, "Get Key:<%s>, but value is NULL", key); index_free(idx); }
void ConflictSet_checkGenerationComplete( ConflictSet *conflictSet, Generation *generation ) { if( Generation_isComplete( generation ) ) { __DEBUG( "Generation %d is complete for dboid %s", generation->number, conflictSet->dboid ); EventQueue_push( conflictSet->stabEventQueue, conflictSet->dboid ); } //__DEBUG( "Generation %d is not complete", generation->number ); }
int handleCAN_COM_goMCUReset(CAN_DataNode stCANMessage) { __DEBUG("Now MCU Reset!\r\n\n"); //Keep priority group unchanged SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) | (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | SCB_AIRCR_SYSRESETREQ_Msk); //Ensure completion of memory access __DSB(); //Waiting for reset while(1); return 0; }
int skiplist_insert(struct skiplist *list,struct slice *sk,UINT val,OPT opt) { int i, new_level; struct skipnode *update[MAXLEVEL+1]; struct skipnode *x; char *key=sk->data; if(!skiplist_notfull(list)) return 0; x = list->hdr; for (i = list->level; i >= 0; i--) { while (x->forward[i] != NIL && cmp_lt(x->forward[i]->key, key)) x = x->forward[i]; update[i] = x; } x = x->forward[0]; if (x != NIL && cmp_eq(x->key, key)){ x->val = val; x->opt = opt; return(1); } for (new_level = 0; rand() < RAND_MAX/2 && new_level < MAXLEVEL; new_level++); if (new_level > list->level) { for (i = list->level + 1; i <= new_level; i++) update[i] = NIL; list->level = new_level; } if ((x =pool_alloc(list,sizeof(struct skipnode) + new_level*sizeof(struct skipnode *))) == 0) __DEBUG("%s","memory *ERROR*"); memcpy(x->key,key,sk->len); x->val=val; x->opt=opt; for (i = 0; i <= new_level; i++) { x->forward[i] = update[i]->forward[i]; update[i]->forward[i] = x; } list->count++; return(1); }
int Generation_isComplete( Generation *generation ) { int it; /* Iterate each replica and check update type * If any of the replicas have GEN_NONE, the generation is not complete */ for( it = 0; it < PRIDE_NUM_REPLICAS; it++ ) { if (generation->generationType[ it ] == GEN_NONE ) { __DEBUG( "Replica %d on generation %d is empty", it, generation->number ); return 0; } } return 1; }
void Transaction_commit( Transaction *transaction ) { pthread_mutex_t *lock; g_hash_table_replace( __conf.conflictSets, transaction->conflictSet->dboid, transaction->conflictSet ); lock = g_hash_table_lookup( __conf.transactionLocks, transaction->conflictSet->dboid ); pthread_mutex_unlock( lock ); __DEBUG( "Released a transaction lock on conflict set" ); ConflictSet_notifyPropagation( transaction->conflictSet ); }
// // Default implementation filling the buffer before turning around to anOutput. // EXPORT_C TStreamTransfer TStreamBuf::DoWriteL(MStreamOutput& anOutput,TStreamTransfer aTransfer) { __ASSERT_DEBUG(aTransfer>0,Panic(EStreamWriteNoTransfer)); __ASSERT_DEBUG(Ptr(EWrite)!=NULL||End(EWrite)==NULL,Panic(EStreamCannotWrite)); __ASSERT_DEBUG(Avail(EWrite)>=0,User::Invariant()); TInt len=aTransfer[Avail(EWrite)]; if (len>0) { __DEBUG(TInt avail=Avail(EWrite)); // may be pulling from this streambuf TUint8* ptr=Ptr(EWrite); len=anOutput.PullL(ptr,len); __ASSERT_DEBUG(len>=0&&len<=aTransfer[avail]&&Ptr(EWrite)==ptr&&Avail(EWrite)>=avail,Panic(EStreamPullInBreach)); SetPtr(EWrite,ptr+len); aTransfer-=len; } if (aTransfer>0) aTransfer=anOutput.WriteToL(*this,aTransfer); return aTransfer; }
/** Reads data from the intermediate buffer and, if necessary, any remaining data from the stream to the specified target stream input object. It is called by ReadL(MStreamInput&,TStreamTransfer). The intermediate buffer is emptied first by calling the target stream input's PushL() function, which performs the read from intermediate buffer operation. Any remaining data is then read from the stream by calling the target stream object's ReadFromL() function, which performs the read from stream operation. This implementation is called for streams that have buffering capabilities and are derived from this class. @param anInput The target stream input object. @param aTransfer A stream transfer object defining the amount of data available to be written. @return The amount of data that was not consumed. @see MStreamInput::ReadFromL() @see MStreamInput::PushL() */ EXPORT_C TStreamTransfer TStreamBuf::DoReadL(MStreamInput& anInput,TStreamTransfer aTransfer) { __ASSERT_DEBUG(aTransfer>0,Panic(EStreamReadNoTransfer)); __ASSERT_DEBUG(Ptr(ERead)!=NULL||End(ERead)==NULL,Panic(EStreamCannotRead)); __ASSERT_DEBUG(Avail(ERead)>=0,User::Invariant()); TInt len=aTransfer[Avail(ERead)]; if (len>0) { __DEBUG(TInt avail=Avail(ERead)); // may be pushing into this streambuf TUint8* ptr=Ptr(ERead); len=anInput.PushL(ptr,len); __ASSERT_DEBUG(len>=0&&len<=aTransfer[avail]&&Ptr(ERead)==ptr&&Avail(ERead)>=avail,Panic(EStreamPushInBreach)); SetPtr(ERead,ptr+len); aTransfer-=len; } if (aTransfer>0) aTransfer=anInput.ReadFromL(*this,aTransfer); return aTransfer; }
int index_add(struct index *idx, struct slice *sk, struct slice *sv) { uint64_t value_offset; struct skiplist *list; struct skiplist *new_list; value_offset = log_append(idx->log, sk, sv); list = idx->list; if(!list) { __DEBUG(LEVEL_ERROR, "ERROR: List<%d> is NULL", idx->lsn); return 0; } if(!skiplist_notfull(list)) { idx->bg_merge_count++; /* If the detached-merge thread isnot finished, hold on it * Notice: it will block the current process, * but it happens only once in a thousand years on production environment. */ pthread_mutex_lock(&idx->merge_mutex); /* start to merge with detached thread */ pthread_t tid; idx->park->list = list; idx->park->lsn = idx->lsn; pthread_mutex_unlock(&idx->merge_mutex); pthread_create(&tid, &idx->attr, _merge_job, idx); idx->mtbl_rem_count = 0; new_list = skiplist_new(idx->max_mtbl_size); idx->list = new_list; idx->lsn++; log_next(idx->log, idx->lsn); } skiplist_insert(idx->list, sk->data, value_offset, sv == NULL ? DEL : ADD); idx->mtbl_rem_count++; return 1; }
CP *cp_open(const char *path) { int i; sst_t *sst; CP *cp; DIR *dp; struct dirent *dir; char sstfile[_PATH_MAX] = {0}; if (!path || !(dp = opendir(path))) return(NULL); if (!(cp = calloc(1,sizeof(CP)))) { closedir(dp); return(NULL); } for (i = 0; i < _SLOTTAG_MAX; i++) cp->cp_slot[i] = sloter_new(); snprintf(cp->cp_path,_PATH_MAX,"%s",path); while ((dir = readdir(dp)) != NULL) { if (strcmp(dir->d_name,".") == 0 || strcmp(dir->d_name,"..") == 0) continue; if (strstr(dir->d_name,_SST_SUFFIX) != NULL) { snprintf(sstfile,_PATH_MAX,"%s/%s",path,dir->d_name); if (!(sst = sstable_open(sstfile,SST_CPONLY))) { __DEBUG(); continue; } sloter_add(cp->cp_slot[sst->stat.slottag],sst); } } cp->pcp = _cp_pcp; cp->runcp = _cp_runcp; cp->close = _cp_close; cp->_sst_link = __cp_sst_link; cp->_sst_unlink = __cp_sst_unlink; closedir(dp); return(cp); }
void push_frame(contextDef* context, u1 localVariableCount, u2 dstClassIndex, codeIndex dest, BOOL returnFromVM) { __DEBUG("call: 0x%04x", dest); // Push previous frame pointer: operandStackPushU2(context, context->framePointer); // Push return address: operandStackPushU2(context, context->programCounter); // Push current class index: operandStackPushU2(context, context->classIndex); // Push current context pointer: operandStackPushU2(context, context->contextPointer); operandStackPushU2(context, returnFromVM ? 1 : 0); // Clear return - flag: context->returnFromVM = FALSE; // Save address of context: context->contextPointer = context->stackPointer; size_t numberOfPushedRegisters = 5; context->framePointer = context->stackPointer - localVariableCount - numberOfPushedRegisters; context->classIndex = dstClassIndex; context->programCounter = dest; }
void silopit_merge(struct silopit *silopit, struct jikukan *list, int fromlog) { struct skipnode *x= list->hdr->forward[0]; if (fromlog == 1) { struct skipnode *cur = x; struct skipnode *first = list->hdr; __DEBUG(LEVEL_DEBUG, "adding log items to hiraishinfilter"); while (cur != first) { if (cur->opt == ADD) hiraishin_add(silopit->hiraishin, cur->key); cur = cur->forward[0]; } } if (silopit->meta->size == 0) _flush_new_list(silopit, x, list->count); else _flush_list(silopit, x, list->hdr, list->count); jikukan_free(list); }