void creat_main() { int ct,BID_ct; int ct_id; int bid_cnt; int total_cnt[2]; int edit_cc; struct BN_LIST *BN_ptr; unsigned char WKpath[PATHSIZE+1]; if ( (BATCH_infof =fileopen(BATCH_INFO,"w+")) == 0) /* DL VT ctrw -> w+ */ { disperr("COULD NOT creat %s",BATCH_INFO); pr_exit(-1); } setmidwin(); clrscr(); BN_ptr= BN_list; for (ct =0; BN_cnt > ct; ct++) { BID_ct= BN_ptr->bnbid_cnt; charfill(Pathbuf,PATHSIZE+1,NULL); strcatl(Pathbuf,Path_bn,"/",BN_ptr->bnptr_bn,NULL); bid_cnt = 0; total_cnt[0] = total_cnt[1] = 0; /* total rec ccount */ for( ct_id=0;BID_ct >ct_id;ct_id++) { charfill(WKpath,PATHSIZE+1,NULL); strcatl(WKpath,Pathbuf,"/.",BN_ptr->bnptr_bid[ct_id],NULL); /* DL VT . added */ if ((Infile= fileopen(WKpath,"r") ) == NULL) { disperr("COULD NOT open fci_file(%s)",WKpath); continue; } edit_cc = edit_data(Create_sel, total_cnt); if (edit_cc == 1) { curpos(0,14); display("FILE= %s",WKpath); rollup(); edit_out(); bid_cnt++; } fileclose(Infile); } BN_ptr++; } resetwin(); fileclose(BATCH_infof); }
int do_open(const char *path, int mode) { int fd; struct file *f; struct inode *ip; if ((mode & O_CREATE) &&!(ip = icreate(path, T_FILE, 0, 0))) return -1; else if (!(ip = namei(path))) return -1; if (ip->type == T_DIR && mode != O_RDONLY) { iput(ip); return -1; } if (!(f = filealloc()) || (fd = fdalloc()) < 0) { if (f) fileclose(f); iput(ip); return -1; } f->type = FD_INODE; f->ip = ip; f->off = 0; f->readable = !(mode & O_WRONLY); f->writable = (mode & O_WRONLY) || (mode & O_RDWR); fs_current->ofile[fd] = f; return fd; }
// Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { struct proc *p; int fd; if(proc == initproc) panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++) { if(proc->ofile[fd]) { fileclose(proc->ofile[fd]); proc->ofile[fd] = 0; } } begin_op(); iput(proc->cwd); end_op(); proc->cwd = 0; acquire(&ptable.lock); // Parent might be sleeping in wait(). wakeup1(proc->parent); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) { if(p->parent == proc && p->is_thread == 1) { p->killed = 1; if(p->state == SLEEPING) { p->state = RUNNABLE; } } } for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) { if(p->parent == proc) { if (p->state == ZOMBIE) { p->killed = 1; } join(p->pid); } } for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) { if(p->parent == proc) { p->parent = initproc; if(p->state == ZOMBIE) wakeup1(initproc); } } // Jump into the scheduler, never to return. proc->state = ZOMBIE; sched(); panic("zombie exit"); }
void texit(void) { // struct proc *p; int fd; if(proc == initproc) panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd]){ fileclose(proc->ofile[fd]); proc->ofile[fd] = 0; } } iput(proc->cwd); proc->cwd = 0; acquire(&ptable.lock); // Parent might be sleeping in wait(). wakeup1(proc->parent); // Pass abandoned children to init. // for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ // if(p->parent == proc){ // p->parent = initproc; // if(p->state == ZOMBIE) // wakeup1(initproc); // } // } // Jump into the scheduler, never to return. proc->state = ZOMBIE; sched(); panic("zombie exit"); }
void snapshot(double ***f1,double **nu,double t_cur,long count) { char str[256]; char message[10]="message"; long tag=count,v; FILE *fd; sprintf(str,"%s_%d_%ld.snp",NameSnapFile,size,count); boundary_conditions(f1,nut); if(rank!=0) MPI_Recv(message,0,MPI_CHAR,rank-1,tag,MPI_COMM_WORLD,statuses); fd=fileopen(str,rank); Master nmessage("snap has been started",t_cur,count); Master fprintf(fd,"current time = %0.10f \ncurrent iteration = %ld\n",t_cur,count); Master fprintf(fd,"number of processors along axes={%d,%d}\n",pp[0],pp[2]); Master fprintf(fd,"Number of points along x = %d\n",N1); Master fprintf(fd,"Number of points along z = %d\n",N3); Master fprintf(fd,"Reynolds number = %lf\n",Re); for(v=0;v<nvar;v++) print_array2d(fd,f1[v],0,m1,0,m3); print_array2d(fd,nu,0,m1,0,m3); fileclose(fd); if(rank!=size-1) MPI_Send(message,0,MPI_CHAR,rank+1,tag,MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD); Master {nmessage("snap is done",t_cur,count); add_control_point(str);} }
int write_all_histograms (const char *fname) { FILE *file; HISTOGRAM *histo; IO_BUFFER *iobuf = NULL; int rc; if ( (histo = get_first_histogram()) == NULL ) { fprintf(stderr,"No histograms to write.\n"); return -4; } if ( (file = fileopen(fname,"w")) == NULL ) { perror(fname); return -1; } if ( (iobuf = allocate_io_buffer(8000000)) == NULL ) return -1; iobuf->max_length = 800000000; iobuf->output_file = file; rc = write_histograms(NULL,-1,iobuf); free_io_buffer(iobuf); fileclose(file); return rc; }
int pipealloc(struct file **f0, struct file **f1) { struct pipe *p; p = 0; *f0 = *f1 = 0; if ((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) { goto bad; } if ((p = (struct pipe *)kalloc()) == 0) { goto bad; } p->readopen = 1; p->writeopen = 1; p->nwrite = 0; p->nread = 0; initlock(&p->lock, "pipe"); (*f0)->type = FD_PIPE; (*f0)->readable = 1; (*f0)->writable = 0; (*f0)->pipe = p; (*f1)->type = FD_PIPE; (*f1)->readable = 0; (*f1)->writable = 1; (*f1)->pipe = p; return 0; //PAGEBREAK: 20 bad: if (p) { kfree((char *)p); } if (*f0) { fileclose(*f0); } if (*f1) { fileclose(*f1); } return -1; }
void init_param(int argc, char** argv,double *dtnext,int flag) { int ver; FILE *iop; double d; if(argc<2 || (iop=fopen(argv[1],"r"))==NULL) //no ini file nrerror("Start from no ini file!",-1,-1); if(fscanf(iop,"%d",&ver)<1 || ver!=2) nrerror("parameters' file has wrong version",0,0); read_token(iop,&rc); read_token(iop,&R); read_token(iop,&Re); read_token(iop,¶bole); read_token(iop,&Noise); read_token(iop,&NoiseNorm); read_token(iop,&UpLimit); read_token(iop,&chimax); read_token(iop,&d); N1 = (int)d; read_token(iop,&d); N3 = (int)d; read_token(iop,&d); nvar = (int)d; read_token(iop,&d); approx = (int)d; read_token(iop,dtnext); read_token(iop,&d); max_okr = (int)d; read_token(iop,&d); OutStep = (int)d; read_token(iop,&d); SnapStep = (int)d; read_token(iop,&SnapDelta); if(ver>=2) read_token(iop,&DumpInterval); if(ver>=2) read_token(iop,&d); DumpKeep = (int)d; read_token(iop,&d); CheckStep = (int)d; read_token(iop,&d); VarStep = (int)d; read_token(iop,&Ttot); read_token(iop,&ChangeParamTime); read_token(iop,&DeltaParam); read_token(iop,&d); if(flag) { if(d==0) { goon = 0; strcpy(NameInitFile,"END"); } else if(d>0) { goon = 1; sprintf(NameInitFile,"%s_%d_%05d.snp",NameSnapFile,size,(int)d); } else {// without reading (d<0) goon=0; strcpy(NameInitFile,"-1"); } } Master if(!goon && !count) nmessage("Parameters were extracted from file",0,0); fileclose(iop); Gamma=1e-4; ghost=(approx-1)/2+3; //radius of approx sample dx[0]=2*R/N1; dx[2]=2*R/N3; p1 = 4/Re; }
// Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { struct proc *p; int fd; if(proc == initproc) panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd]){ fileclose(proc->ofile[fd]); proc->ofile[fd] = 0; } } iput(proc->cwd); proc->cwd = 0; acquire(&ptable.lock); // Parent might be sleeping in wait(). wakeup1(proc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->pid == proc->pid && p->state != ZOMBIE){ //undead thread p->state = ZOMBIE; if(p->is_thread){//it is a thread if(p->parent->num_of_thread_child){ p->parent->num_of_thread_child--; } //no more childran if(!p->parent->num_of_thread_child){ wakeup1(p->parent->parent); } } else{//it is a proccees p->num_of_thread_child--; if(!p->num_of_thread_child){ wakeup1(p->parent); } } } else if(p->parent == proc && p->is_thread !=1){// a proccess child p->parent = initproc; if(p->state == ZOMBIE){ wakeup1(initproc); } } } // Jump into the scheduler, never to return. proc->state = ZOMBIE; sched(); panic("zombie exit"); }
void add_control_point(char *name_cp) { FILE *cpf; cpf = fileopen(NameCPFile,1); if(cpf==NULL) cpf=fileopen(NameCPFile,0); fprintf(cpf,"%s\n",name_cp); fileclose(cpf); }
int do_close(int fd) { if (fd < 0 || fd >= NOFILE || !fs_current->ofile[fd]) return -1; fileclose(fs_current->ofile[fd]); fs_current->ofile[fd] = NULL; return 0; }
/* Read the list of unsolvable levels from the given filename. If the * filename does not contain a path, then the function looks for the * file in the resource directory and the user's save directory. */ int loadunslistfromfile(char const *filename) { fileinfo file; memset(&file, 0, sizeof file); if (openfileindir(&file, resdir, filename, "r", NULL)) { readunslist(&file); fileclose(&file, NULL); } if (!haspathname(filename)) { memset(&file, 0, sizeof file); if (openfileindir(&file, savedir, filename, "r", NULL)) { readunslist(&file); fileclose(&file, NULL); } } return TRUE; }
int init_data(void) //returns code of error { int error=0; int i,j,k,l,tmpr; char fstr[256], pos; float tmpf; char tmpc; double Re1; // priority for parameter in snap-file FILE *inp; pos = strcspn(NameInitFile,"*"); NameInitFile[pos]=0; sprintf(fstr,"%s%d%s",NameInitFile,rank+0*size,NameInitFile+pos+1); inp = fileopen(fstr,-1); read_tilleq(inp,'=','n'); if(fscanf(inp,"%lf",&t_cur)==0) error=1; read_tilleq(inp,'=','n'); if(fscanf(inp,"%ld",&count)==0) error=1; read_tilleq(inp,'=','n'); if(fscanf(inp,"%c%d%c%d%c%d%c",&tmpc,&pp[0],&tmpc,&pp[1],&tmpc,&pp[2],&tmpc)<7) error=1; //no need unless process distribution is written if(pp[0]*pp[1]*pp[2]!=size) nrerror("Wrong number of processors in data file. Can't read data.",-1,-1); read_tilleq(inp,'=','n'); if(fscanf(inp,"%d",&N1)==0) error=1; read_tilleq(inp,'=','n'); if(fscanf(inp,"%d",&N2)==0) error=1; read_tilleq(inp,'=','n'); if(fscanf(inp,"%d",&N3)==0) error=1; read_tilleq(inp,'=','n'); if(fscanf(inp,"%lf",&Re1)==0) error=1; // fgetc(inp); fgetc(inp); read_tilleq(inp,0x0A,'n'); init_parallel(); operate_memory(1); // creating arrays // for(tmpr=0;tmpr<=rank;tmpr++) //reading until arrays of this process // { for(l=0;l<nvar;l++) // reading f for(i=0;i<m1;i++) for(j=0;j<m2;j++) for(k=0;k<m3;k++) { if(fread(&tmpf,sizeof(float),1,inp)<1) error=2*(k+100*(j+100*i)); f[l][i][j][k] = tmpf; } for(i=0;i<m1;i++) for(j=0;j<m2;j++) for(k=0;k<m3;k++) { if(fread(&tmpf,sizeof(float),1,inp)<1) error=3*(k+100*(j+100*i)); nut[i][j][k] = tmpf; } // } fileclose(inp); if(error) nrerror("Data couldn't have been read from file!!!",-1,error); else Master nmessage("Data has been read from file",t_cur,count); return(error); }
/* * Performs Solaris dependent mapping. Returns a zone ID if * found. Otherwise, NULL is returned. Solaris libc looks up * "/etc/default/init" to get the default TZ value if TZ is not defined * as an environment variable. */ static char * getPlatformTimeZoneID() { char *tz = NULL; FILE *fp; /* * Try the TZ entry in /etc/default/init. */ if ((fp = fileopen(SYS_INIT_FILE, "r")) != NULL) { char line[256]; char quote = '\0'; while (filegets(line, sizeof(line), fp) != NULL) { char *p = line; char *s; char c; /* quick check for comment lines */ if (*p == '#') { continue; } if (strncmp(p, "TZ=", 3) == 0) { p += 3; SKIP_SPACE(p); c = *p; if (c == '"' || c == '\'') { quote = c; p++; } /* * PSARC/2001/383: quoted string support */ for (s = p; (c = *s) != '\0' && c != '\n'; s++) { /* No '\\' is supported here. */ if (c == quote) { quote = '\0'; break; } if (c == ' ' && quote == '\0') { break; } } if (quote != '\0') { jio_fprintf(stderr, "ZoneInfo: unterminated time zone name in /etc/TIMEZONE\n"); } *s = '\0'; tz = strdup(p); break; } } (void) fileclose(fp); } return tz; }
//Done int sys_close(int fd) { struct file *f; f = fdlookup(fd); proc->ofile[fd] = 0; fileclose(f); return 0; }
void nmessage(char msg_text[],double t_cur,long count) { FILE *msg; msg=fileopen(NameMessageFile,1); time_now = (t_cur<0)?time_begin:MPI_Wtime(); fprintf(msg,"message of proc#%d at t=%-7.4lf Niter=%-6d time of work=%g sec:\n",rank, t_cur,count,time_now-time_begin); fprintf(msg,"%s\n",msg_text); fileclose(msg); }
// Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { struct proc *p; int fd; if(proc == initproc) panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd]){ fileclose(proc->ofile[fd]); proc->ofile[fd] = 0; } } #ifndef SELECTION_NONE #ifdef VERBOSE_PRINT_TRUE char* state; if(proc->state >= 0 && proc->state < NELEM(states) && states[proc->state]) state = states[proc->state]; else state = "???"; print_proc_data(proc, state); cprintf("\n"); #endif free_proc_pgmd(proc,1); //remove swap file and pages metadata #endif begin_op(); iput(proc->cwd); end_op(); proc->cwd = 0; acquire(&ptable.lock); // Parent might be sleeping in wait(). wakeup1(proc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent == proc){ p->parent = initproc; if(p->state == ZOMBIE) wakeup1(initproc); } } // Jump into the scheduler, never to return. proc->state = ZOMBIE; sched(); panic("zombie exit"); }
int sys_close(int fd) { struct file *f; if(argfd(0, &fd, &f) < 0) return -1; proc->ofile[fd] = 0; fileclose(f); return 0; }
void swapOut(struct proc* p) { //write to file char filename[9]; struct file* f; uint i; pte_t* pte=0; getSwapFileName(p, filename); //cprintf("swapout %s %d\n", p->name, p->pid); //release(&inswapper_lk); //acquire(&inswapper_lk); release(&ptable.lock); f = openKernelFile(filename, O_CREATE | O_WRONLY); acquire(&ptable.lock); //cprintf("sfff\n"); //release(&inswapper_lk); if(f == 0) panic("swapout: file open error\n"); //cprintf("swapout: before write\n"); int freed = 0; for (i = 0; i < p->sz; i += PGSIZE) { if (!(pte = walkpgdir(p->pgdir, (void *) i, 0))) panic("swapout: pte should exist\n"); //cprintf("walkpgdir: ok\n"); if (!(*pte & PTE_P)) panic("swapout: page not present\n"); if((*pte & PTE_SHR) || !(*pte & PTE_U)) continue; char *addr=(char*)p2v(PTE_ADDR(*pte)); //acquire(&inswapper_lk); release(&ptable.lock); filewrite(f, addr, PGSIZE); acquire(&ptable.lock); // release(&inswapper_lk); //cprintf("(w=%s)", addr); kfree(addr); *pte = 0; freed++; //cprintf("swapout: wrote %d\n",i/PGSIZE); } //cprintf("swapout freed %d\n", freed); //kfree((char*) p->pgdir); //cprintf("swapout: after write\n"); //freevm(p->pgdir); // acquire(&inswapper_lk); release(&ptable.lock); fileclose(f); acquire(&ptable.lock); // release(&inswapper_lk); }
void putlog(char msg_text[],long num) { FILE *log; char name[20]; sprintf(name,"mess%d.log",rank); log=fileopen(name,num); time_now = (num==0)?time_begin:MPI_Wtime(); fprintf(log,"message at t=%-7.4lf Niter=%-6d time of work=%g sec\n", t_cur,count,time_now-time_begin); fprintf(log,"%s %d\n",msg_text,num); fileclose(log); }
void delfile(File *f) { int w = whichmenu(f); if(w < 0) /* e.g. x/./D */ return; if(downloaded) outTs(Hdelname, f->tag); dellist(&file, w); fileclose(f); }
int pipealloc(struct file **f0, struct file **f1) { struct pipe *p; p = 0; *f0 = *f1 = 0; if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) goto bad; if((p = (struct pipe*)kalloc(PAGE)) == 0) goto bad; p->readopen = 1; p->writeopen = 1; p->writep = 0; p->readp = 0; initlock(&p->lock, "pipe"); (*f0)->type = FD_PIPE; (*f0)->readable = 1; (*f0)->writable = 0; (*f0)->pipe = p; (*f1)->type = FD_PIPE; (*f1)->readable = 0; (*f1)->writable = 1; (*f1)->pipe = p; return 0; bad: if(p) kfree((char*)p, PAGE); if(*f0){ (*f0)->type = FD_NONE; fileclose(*f0); } if(*f1){ (*f1)->type = FD_NONE; fileclose(*f1); } return -1; }
// Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { struct proc *p; int fd; if(proc == initproc) panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd] && proc->thread == 0){ fileclose(proc->ofile[fd]); proc->ofile[fd] = 0; } } begin_op(); iput(proc->cwd); end_op(); proc->cwd = 0; acquire(&ptable.lock); // Parent might be sleeping in wait(). wakeup1(proc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->thread == 1 && p->parent == proc){ p->killed = 1; if(p->state == SLEEPING) // Wake process from sleep if necessary p->state = RUNNABLE; release(&ptable.lock); join(p->pid); acquire(&ptable.lock); p->parent = initproc; if(p->state == ZOMBIE) wakeup1(initproc); } else if(p->parent == proc){ p->parent = initproc; if(p->state == ZOMBIE) wakeup1(initproc); } } // Jump into the scheduler, never to return. proc->state = ZOMBIE; sched(); panic("zombie exit"); }
static int devmem_close(int fd, Pfd_t* fpd, int noclose) { Pdev_t *pdev = dev_ptr(fpd->devno); int r; if(fpd->refcount> pdev->count) badrefcount(fd, fpd ,pdev->count); r = fileclose(fd, fpd, noclose); if(pdev->count<=0) ; else InterlockedDecrement(&pdev->count); return r; }
void swapIn(struct proc* p) { //read from file char filename[9]; struct file* f; uint i; char* buff; pte_t* pte; //cprintf("swapin %s %d\n", p->name, p->pid); getSwapFileName(p, filename); release(&ptable.lock); f = openKernelFile(filename, O_RDWR); //cprintf("1"); acquire(&ptable.lock); if(f == 0) panic("swapin: file open error\n"); f->off = 0; //p->pgdir = setupkvm(); if (!p->pgdir) panic("swapin: setupkvm failed\n"); int recovered = 0; for (i = 0; i < p->sz; i += PGSIZE) { if((pte = walkpgdir(p->pgdir, (char*) i, 0)) == 0){ //cprintf("skip"); //continue; } if(*pte != 0) continue; if (!(buff = kalloc())) panic("swapin: kalloc failed\n"); release(&ptable.lock); fileread(f, buff, PGSIZE); acquire(&ptable.lock); //cprintf("(%s)", buff); if (mappages(p->pgdir, (void*) i, PGSIZE, v2p(buff), PTE_W | PTE_U) < 0) panic("swapin: mappages failed\n"); recovered++; } //cprintf("swapin recovered %d\n", recovered); release(&ptable.lock); fileclose(f); //cprintf("swapin2"); //unlinkKernelFile(filename); acquire(&ptable.lock); //cprintf("swapin3"); }
void nrerror(char error_text[],double t_cur,long count) { FILE *err; nmessage(error_text,t_cur,count); err=fileopen(NameErrorFile,0); fprintf(err,"Run-time error of proc#%d at t=%-6.4lf:\n",rank,t_cur); fprintf(err,"%s\n",error_text); fprintf(err,"...now exiting to system...\n"); fileclose(err); if(f) operate_memory(-1); add_control_point("END"); // MPI_Finalize(); exit(1); }
// Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { struct proc *p; int fd; if(proc == initproc) panic("init exiting"); // cprintf("pid: %d is exiting\n",proc->pid); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd]){ fileclose(proc->ofile[fd]); proc->ofile[fd] = 0; } } // part 2 int j; for(j=0 ; j < 200 ; j++) unlockInodesTable[proc->pid][j] = 0; iput(proc->cwd); proc->cwd = 0; acquire(&ptable.lock); // Parent might be sleeping in wait(). wakeup1(proc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent == proc){ p->parent = initproc; if(p->state == ZOMBIE) wakeup1(initproc); } } // Jump into the scheduler, never to return. proc->state = ZOMBIE; sched(); panic("zombie exit"); }
void dump(double ***f1,double **nu,double t_cur,long count) { char str[256],str1[256]; FILE *fd; int v; struct stat st = {0}; if (stat("dump", &st) == -1) { mkdir("dump", 0777); } if(DumpKeep) sprintf(str,"dump/%s_%d_%ld.dmp",NameSnapFile,rank,count); else { sprintf(str,"dump/%s%d.dmp",NameSnapFile,rank); sprintf(str1,"dump/%s%d.bak",NameSnapFile,rank); remove(str1); rename(str,str1); } // if(rank!=0) MPI_Recv("dump",0,MPI_CHAR,rank-1,/*tag*/1,MPI_COMM_WORLD,statuses); fd=fileopen(str,rank); //Master { // для вывода в один файл, иначе убрать!! // nmessage("dump has been started",t_cur,count); fprintf(fd,"current time = %0.10f \ncurrent iteration = %ld\n",t_cur,count); fprintf(fd,"number of processors along axes={%d,%d}\n",pp[0],pp[2]); fprintf(fd,"Number of points along x = %d\n",N1); fprintf(fd,"Number of points along z = %d\n",N3); fprintf(fd,"Reynolds number = %lf\n",Re); //} for(v=0;v<nvar;v++) print_array2d(fd,f1[v],0,m1,0,m3); print_array2d(fd,nu,0,m1,0,m3); fileclose(fd); // if(rank!=size-1) MPI_Send(message,0,MPI_CHAR,rank+1,tag,MPI_COMM_WORLD); MPI_Barrier(MPI_COMM_WORLD); Master { nmessage("dump is done",t_cur,count); if(DumpKeep) sprintf(str,"dump/%s_*_%ld.dmp",NameSnapFile,count); else sprintf(str,"dump/%s*.dmp",NameSnapFile); add_control_point(str); } }
/* * Edit a message list. */ static int edit1(struct msg* msgvec, int type) { register struct msg* ip; register struct msg* mp; FILE* fp; off_t size; sig_t sigint; /* * Deal with each message to be edited . . . */ for (ip = msgvec; ip->m_index; ip++) { if (ip > msgvec) { char buf[100]; char* p; note(PROMPT, "Edit message %d [ynq]? ", ip->m_index); if (!fgets(buf, sizeof buf, stdin)) break; for (p = buf; isspace(*p); p++); if (*p == 'q' || *p == 'Q') break; if (*p == 'n' || *p == 'N') continue; } state.msg.dot = mp = state.msg.list + ip->m_index - 1; touchmsg(mp); sigint = signal(SIGINT, SIG_IGN); if (fp = run_editor(setinput(mp), mp->m_size, NiL, type, state.readonly)) { if (!state.msg.op) settmp(NiL, 0); fseek(state.msg.op, (off_t)0, SEEK_END); size = ftell(state.msg.op); mp->m_block = blocknumber(size); mp->m_offset = blockoffset(size); msgflags(mp, MODIFY, 0); rewind(fp); filecopy(NiL, fp, state.tmp.dir, state.msg.op, NiL, (off_t)0, &mp->m_lines, &mp->m_size, 0); fileclose(fp); } signal(SIGINT, sigint); } return 0; }
// Exit the current process. Does not return. // An exited process remains in the zombie state // until its parent calls wait() to find out it exited. void exit(void) { struct proc *p; int fd; if(proc == initproc) panic("init exiting"); // Close all open files. for(fd = 0; fd < NOFILE; fd++){ if(proc->ofile[fd]){ fileclose(proc->ofile[fd]); proc->ofile[fd] = 0; } } iput(proc->cwd); proc->cwd = 0; acquire(&ptable.lock); // Parent might be sleeping in wait(). wakeup1(proc->parent); // Pass abandoned children to init. for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ if(p->parent == proc){ p->parent = initproc; if(p->state == ZOMBIE) wakeup1(initproc); } } // Jump into the scheduler, never to return. proc->state = ZOMBIE; //**** remove--this may be unneccessary //cprintf("remove in exit\n"); removefromq(proc); //**** sched(); panic("zombie exit"); }