/* * mount 'source_mnt' under the destination 'dest_mnt' at * dentry 'dest_dentry'. And propagate that mount to * all the peer and slave mounts of 'dest_mnt'. * Link all the new mounts into a propagation tree headed at * source_mnt. Also link all the new mounts using ->mnt_list * headed at source_mnt's ->mnt_list * * @dest_mnt: destination mount. * @dest_dentry: destination dentry. * @source_mnt: source mount. * @tree_list : list of heads of trees to be attached. */ int propagate_mnt(struct mount *dest_mnt, struct mountpoint *dest_mp, struct mount *source_mnt, struct hlist_head *tree_list) { struct mount *m, *n; int ret = 0; /* * we don't want to bother passing tons of arguments to * propagate_one(); everything is serialized by namespace_sem, * so globals will do just fine. */ user_ns = current->nsproxy->mnt_ns->user_ns; last_dest = dest_mnt; last_source = source_mnt; mp = dest_mp; list = tree_list; dest_master = dest_mnt->mnt_master; /* all peers of dest_mnt, except dest_mnt itself */ for (n = next_peer(dest_mnt); n != dest_mnt; n = next_peer(n)) { ret = propagate_one(n); if (ret) goto out; } /* all slave groups */ for (m = next_group(dest_mnt, dest_mnt); m; m = next_group(m, dest_mnt)) { /* everything in that slave group */ n = m; do { ret = propagate_one(n); if (ret) goto out; n = next_peer(n); } while (n != m); } out: read_seqlock_excl(&mount_lock); hlist_for_each_entry(n, tree_list, mnt_hash) { m = n->mnt_parent; if (m->mnt_master != dest_mnt->mnt_master) CLEAR_MNT_MARK(m->mnt_master); }
/// Returns the next variable in a group, recursing into groups /// as needed AP_Param *AP_Param::next_group(uint8_t vindex, const struct GroupInfo *group_info, bool *found_current, uint8_t group_base, uint8_t group_shift, ParamToken *token, enum ap_var_type *ptype) { enum ap_var_type type; for (uint8_t i=0; (type=(enum ap_var_type)PGM_UINT8(&group_info[i].type)) != AP_PARAM_NONE; i++) { #ifdef AP_NESTED_GROUPS_ENABLED if (type == AP_PARAM_GROUP) { // a nested group const struct GroupInfo *ginfo = (const struct GroupInfo *)PGM_POINTER(&group_info[i].group_info); AP_Param *ap; ap = next_group(vindex, ginfo, found_current, GROUP_ID(group_info, group_base, i, group_shift), group_shift + _group_level_shift, token, ptype); if (ap != NULL) { return ap; } } else #endif // AP_NESTED_GROUPS_ENABLED { if (*found_current) { // got a new one token->key = vindex; token->group_element = GROUP_ID(group_info, group_base, i, group_shift); token->idx = 0; if (ptype != NULL) { *ptype = type; } return (AP_Param*)(PGM_POINTER(&_var_info[vindex].ptr) + PGM_UINT16(&group_info[i].offset)); } if (GROUP_ID(group_info, group_base, i, group_shift) == token->group_element) { *found_current = true; if (type == AP_PARAM_VECTOR3F && token->idx < 3) { // return the next element of the vector as a // float token->idx++; if (ptype != NULL) { *ptype = AP_PARAM_FLOAT; } uintptr_t ofs = (uintptr_t)PGM_POINTER(&_var_info[vindex].ptr) + PGM_UINT16(&group_info[i].offset); ofs += sizeof(float)*(token->idx-1); return (AP_Param *)ofs; } } } } return NULL; }
void grouped_node_base<A>::unlink_node(bucket& b, node_ptr n) { node_ptr next = n->next_; node_ptr* pos = &next_group(n); if(*pos != n) { // The node is at the beginning of a group. // Find the previous node pointer: pos = &b.next_; while(*pos != n) pos = &next_group(*pos); // Remove from group if(BOOST_UNORDERED_BORLAND_BOOL(next) && get(next).group_prev_ == n) { get(next).group_prev_ = get(n).group_prev_; } } else if(BOOST_UNORDERED_BORLAND_BOOL(next) && get(next).group_prev_ == n) { // The deleted node is not at the end of the group, so // change the link from the next node. get(next).group_prev_ = get(n).group_prev_; } else { // The deleted node is at the end of the group, so the // first node in the group is pointing to it. // Find that to change its pointer. node_ptr x = get(n).group_prev_; while(get(x).group_prev_ != n) { x = get(x).group_prev_; } get(x).group_prev_ = get(n).group_prev_; } *pos = next; }
/// Returns the next variable in _var_info, recursing into groups /// as needed AP_Param *AP_Param::next(ParamToken *token, enum ap_var_type *ptype) { uint8_t i = token->key; bool found_current = false; if (i >= _num_vars) { // illegal token return NULL; } enum ap_var_type type = (enum ap_var_type)PGM_UINT8(&_var_info[i].type); // allow Vector3f to be seen as 3 variables. First as a vector, // then as 3 separate floats if (type == AP_PARAM_VECTOR3F && token->idx < 3) { token->idx++; if (ptype != NULL) { *ptype = AP_PARAM_FLOAT; } return (AP_Param *)(((token->idx-1)*sizeof(float))+(uintptr_t)PGM_POINTER(&_var_info[i].ptr)); } if (type != AP_PARAM_GROUP) { i++; found_current = true; } for (; i<_num_vars; i++) { type = (enum ap_var_type)PGM_UINT8(&_var_info[i].type); if (type == AP_PARAM_GROUP) { const struct GroupInfo *group_info = (const struct GroupInfo *)PGM_POINTER(&_var_info[i].group_info); AP_Param *ap = next_group(i, group_info, &found_current, 0, 0, token, ptype); if (ap != NULL) { return ap; } } else { // found the next one token->key = i; token->group_element = 0; token->idx = 0; if (ptype != NULL) { *ptype = type; } return (AP_Param *)(PGM_POINTER(&_var_info[i].ptr)); } } return NULL; }
lzma_index_read(lzma_index *i, lzma_index_record *info) { if (i->current.group == NULL) { // We are at the beginning of the Record list. Set up // i->current point at the first Record. Return if there // are no Records. if (init_current(i)) return true; } else do { // Try to go the next Record. if (i->current.record < i->current.group->last) ++i->current.record; else if (i->current.group->next == NULL) return true; else next_group(i); } while (i->current.group->paddings[i->current.record]); // We found a new Record. Set the information to *info. set_info(i, info); return false; }
lzma_index_locate(lzma_index *i, lzma_index_record *info, lzma_vli target) { // Check if it is possible to fullfill the request. if (target >= i->uncompressed_size) return true; // Now we know that we will have an answer. Initialize the current // read position if needed. if (i->current.group == NULL && init_current(i)) return true; // Locate the group where the wanted Block is. First search forward. while (i->current.uncompressed_offset <= target) { // If the first uncompressed byte of the next group is past // the target offset, it has to be this or an earlier group. if (i->current.uncompressed_offset + i->current.group ->uncompressed_sums[i->current.group->last] > target) break; // Go forward to the next group. next_group(i); } // Then search backward. while (i->current.uncompressed_offset > target) previous_group(i); // Now the target Block is somewhere in i->current.group. Offsets // in groups are relative to the beginning of the group, thus // we must adjust the target before starting the search loop. assert(target >= i->current.uncompressed_offset); target -= i->current.uncompressed_offset; // Use binary search to locate the exact Record. It is the first // Record whose uncompressed_sums[] value is greater than target. // This is because we want the rightmost Record that fullfills the // search criterion. It is possible that there are empty Blocks or // padding, we don't want to return them. size_t left = 0; size_t right = i->current.group->last; while (left < right) { const size_t pos = left + (right - left) / 2; if (i->current.group->uncompressed_sums[pos] <= target) left = pos + 1; else right = pos; } i->current.record = left; #ifndef NDEBUG // The found Record must not be padding or have zero uncompressed size. assert(!i->current.group->paddings[i->current.record]); if (i->current.record == 0) assert(i->current.group->uncompressed_sums[0] > 0); else assert(i->current.group->uncompressed_sums[i->current.record] - i->current.group->uncompressed_sums[ i->current.record - 1] > 0); #endif set_info(i, info); return false; }
int main() { int totalTime; totalTime = 0; int quantum; int op; int cpp = 0; pcbCtrl *ctrl; pcbStates *states; groupsCtrl *ctrlG; usersCtrl *ctrlU; ctrl = malloc(sizeof(pcbCtrl)); states = malloc(sizeof(pcbStates)); states->readys = malloc(sizeof(pcbCtrl)); states->waiting = malloc(sizeof(pcbCtrl)); states->sleeping = malloc(sizeof(pcbCtrl)); ctrlG = malloc(sizeof(groupsCtrl)); ctrlU = malloc(sizeof(usersCtrl)); printf("\n"); quantum = set_int("Quantum del programa", 1); if(val_npos(quantum, 1) != FAIL) { do { printf("\n \t\t<< SIMULACION DE ALGORITMO DE DESPACHO RONUD-ROBIN >>\n"); print_options(0); printf("\n>"); scanf("%i",&op); getchar(); switch(op) { case 1: printf("\n"); create_group(ctrlG); break; case 2: printf("\n"); create_user(ctrlU); break; case 3: printf("\n"); create_process(cpp,ctrl,states,ctrlG,ctrlU); cpp++; break; case 4: printf("\n"); state_change(ctrl,states); break; case 5: printf("\n"); show_everything(ctrl,states,ctrlG,ctrlU); break; case 6: printf("\n"); rr(states, ctrl, quantum, &totalTime); break; case 7: printf("\n"); del_option(ctrl,states,ctrlG,ctrlU); break; case 8: break; default: printf("Opcion invalida, vuelva a intentarlo.\n"); } }while(op != 8); if(ctrl->front != NULL) { pcb *aux = ctrl->front; while( next_pcb(&aux,ctrl->front) != FAIL ) free(aux); } if(ctrlG->front != NULL) { groups *aux = ctrlG->front; while( next_group(&aux,ctrlG->front) != FAIL ) free(aux); } if(ctrlU->front != NULL) { users *aux = ctrlU->front; while( next_user(&aux,ctrlU->front) != FAIL ) free(aux); } free(ctrl->front); free(ctrlG->front); free(ctrlU->front); free(ctrl); free(ctrlG); free(ctrlU); } return 0; }
int main (int argc, char *argv[]) { int status = 0; static char eoferrmsg[] = "Unexpected end of file in %s section of file \"%s\" (line %d)\n"; parseoptions(argc, argv); InitTables(); InitConvert(); errno = 0; infp = fopen(Inputfile, "r"); if(!infp) { fprintf(stderr, "Can't open file '%s' for input (E%d: %s)\n", Inputfile, errno, strerror(errno)); exit(-1); } /* Initialise group */ Group.line = 0; /* Read DXF file and write Radiance data. */ next_group(infp, &Group); while (!feof(infp) && strcmp(Group.value,FILEEND) != 0) { if(Group.code == 0) { if(strcmp(Group.value, SECTION) == 0) { next_group(infp, &Group); /* code 2 group */ if(strcmp(Group.value,HEADER) == 0) { if(Options.verbose > 0) { fprintf(stderr, " Reading headers\n"); } HeaderSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "HEADER", Inputfile, Group.line); status = -1; } } else if(strcmp(Group.value,CLASSES) == 0) { if(Options.verbose > 0) { fprintf(stderr, " Ignoring classes\n"); } IgnoreSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "CLASSES", Inputfile, Group.line); status = -1; } } else if(strcmp(Group.value,TABLES) == 0) { if(Options.verbose > 0) { fprintf(stderr, " Reading tables\n"); } TablesSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "TABLES", Inputfile, Group.line); status = -1; } } else if(strcmp(Group.value,BLOCKS) == 0) { if(Options.verbose > 0) { fprintf(stderr, " Reading blocks\n"); } BlocksSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "BLOCKS", Inputfile, Group.line); status = -1; } } else if(strcmp(Group.value,ENTITIES) == 0) { if(Options.geom) { int i; time_t ltime; if(*Outputfile == '\0') { outf = stdout; } else { errno = 0; outf = fopen((const char*)&Outputfile, "w"); if(outf == NULL) { fprintf(stderr, "Can't open file '%s' for output (E%d: %s)\n", Outputfile, errno, strerror(errno)); exit(1); } } (void)time(<ime); fprintf(outf, "## Radiance geometry file \"%s\"\n", Outputfile[0] ? Outputfile : "<stdout>"); fprintf(outf, "## Converted by dxf2rad %s: %s##", DXF2RAD_VER, ctime(<ime)); for(i = 0; i < argc; i ++) { fprintf(outf, " %s", argv[i]); } fprintf(outf, "\n\n"); if(Options.verbose > 0) { fprintf(stderr, " Reading entities\n"); } EntitiesSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "ENTITIES", Inputfile, Group.line); status = -1; } } else { if(Options.verbose > 0) { fprintf(stderr, " Ignoring entities\n"); } IgnoreSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "ENTITIES", Inputfile, Group.line); status = -1; } } } else if(strcmp(Group.value,OBJECTS) == 0) { if(Options.verbose > 0) { fprintf(stderr, " Ignoring objects\n"); } IgnoreSection(); if(feof(infp)) { fprintf(stderr, eoferrmsg, "OBJECTS", Inputfile, Group.line); status = -1; } } } } next_group(infp, &Group); } if(outf) { if (status == 0) { fprintf(outf, "\n## End of Radiance geometry file \"%s\"\n\n", Outputfile[0] ? Outputfile : "<stdout>"); } fclose(outf); } fclose(infp); return status; }