void OptoRuntime::generate_exception_blob() { // Capture info about frame layout enum layout { thread_off, // last_java_sp // The frame sender code expects that rbp will be in the "natural" place and // will override any oopMap setting for it. We must therefore force the layout // so that it agrees with the frame sender code. rbp_off, return_off, // slot for return address framesize }; // allocate space for the code ResourceMark rm; // setup code generation tools CodeBuffer buffer("exception_blob", 512, 512); MacroAssembler* masm = new MacroAssembler(&buffer); OopMapSet *oop_maps = new OopMapSet(); address start = __ pc(); __ push(rdx); __ subptr(rsp, return_off * wordSize); // Prolog! // rbp, location is implicitly known __ movptr(Address(rsp,rbp_off *wordSize), rbp); // Store exception in Thread object. We cannot pass any arguments to the // handle_exception call, since we do not want to make any assumption // about the size of the frame where the exception happened in. __ get_thread(rcx); __ movptr(Address(rcx, JavaThread::exception_oop_offset()), rax); __ movptr(Address(rcx, JavaThread::exception_pc_offset()), rdx); // This call does all the hard work. It checks if an exception handler // exists in the method. // If so, it returns the handler address. // If not, it prepares for stack-unwinding, restoring the callee-save // registers of the frame being removed. // __ movptr(Address(rsp, thread_off * wordSize), rcx); // Thread is first argument __ set_last_Java_frame(rcx, noreg, noreg, NULL); __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, OptoRuntime::handle_exception_C))); // No registers to map, rbp is known implicitly oop_maps->add_gc_map( __ pc() - start, new OopMap( framesize, 0 )); __ get_thread(rcx); __ reset_last_Java_frame(rcx, false, false); // Restore callee-saved registers __ movptr(rbp, Address(rsp, rbp_off * wordSize)); __ addptr(rsp, return_off * wordSize); // Epilog! __ pop(rdx); // Exception pc // rax,: exception handler for given <exception oop/exception pc> // We have a handler in rax, (could be deopt blob) // rdx - throwing pc, deopt blob will need it. __ push(rax); // rcx contains handler address __ get_thread(rcx); // TLS // Get the exception __ movptr(rax, Address(rcx, JavaThread::exception_oop_offset())); // Get the exception pc in case we are deoptimized __ movptr(rdx, Address(rcx, JavaThread::exception_pc_offset())); #ifdef ASSERT __ movptr(Address(rcx, JavaThread::exception_handler_pc_offset()), NULL_WORD); __ movptr(Address(rcx, JavaThread::exception_pc_offset()), NULL_WORD); #endif // Clear the exception oop so GC no longer processes it as a root. __ movptr(Address(rcx, JavaThread::exception_oop_offset()), NULL_WORD); __ pop(rcx); // rax,: exception oop // rcx: exception handler // rdx: exception pc __ jmp (rcx); // ------------- // make sure all code is generated masm->flush(); _exception_blob = ExceptionBlob::create(&buffer, oop_maps, framesize); }
void phantom_thread_in_interrupt_fork() { SHOW_INFO0( 10, "ifork in..."); assert( forkLock.lock != 0 ); hal_spin_lock(&schedlock); child = get_thread(GET_CURRENT_THREAD()->child_tid); parent = GET_CURRENT_THREAD(); //#warning cli // Save to me, switch to me SHOW_INFO0( 10, "ifork save..."); phantom_switch_context(parent, parent, &schedlock ); SHOW_INFO0( 10, "ifork saved..."); // (OLD) phantom_switch_context() below returns here in old thread!! if(!(parent->thread_flags & THREAD_FLAG_PREFORK)) { set_esp(old_sp); SHOW_INFO0( 10, "ifork in old..."); // Second return. We're in old tread and done with fork; //GET_CURRENT_THREAD() = parent; SET_CURRENT_THREAD(parent); // Let child be elegible to run child->sleep_flags &= ~THREAD_SLEEP_LOCKED; t_enqueue_runq(child); return; } SHOW_INFO0( 10, "ifork cont..."); parent->thread_flags &= ~THREAD_FLAG_PREFORK; //GET_CURRENT_THREAD() = child; SET_CURRENT_THREAD(child); // Now switch stack and copy some 512 bytes there to make sure // new one will have some place to return to int cp_size = 512; void *from = (void*) (old_sp = get_esp()); void *to = (child->stack) - cp_size - 1; SHOW_INFO0( 10, "ifork memmove..."); memmove(to, from, cp_size); //printf("set ESP...\n"); SHOW_INFO0( 10, "set ESP..."); set_esp((int)to); //#warning sti // Save to new, switch to me -- WILL RETURN TO (X) //printf("ifork GO...\n"); phantom_switch_context(child, parent, &schedlock ); // (NEW) phantom_switch_context() below returns here in new thread!! //printf("ifork in NEW...\n"); }
void manage_gpu(void) { struct thr_info *thr; int selected, gpu, i; char checkin[40]; char input; if (!opt_g_threads) return; opt_loginput = true; immedok(logwin, true); clear_logwin(); retry: for (gpu = 0; gpu < nDevs; gpu++) { struct cgpu_info *cgpu = &gpus[gpu]; double displayed_rolling, displayed_total; bool mhash_base = true; displayed_rolling = cgpu->rolling; displayed_total = cgpu->total_mhashes / total_secs; if (displayed_rolling < 1) { displayed_rolling *= 1000; displayed_total *= 1000; mhash_base = false; } wlog("GPU %d: %.1f / %.1f %sh/s | A:%d R:%d HW:%d U:%.2f/m I:%d\n", gpu, displayed_rolling, displayed_total, mhash_base ? "M" : "K", cgpu->accepted, cgpu->rejected, cgpu->hw_errors, cgpu->utility, cgpu->intensity); #ifdef HAVE_ADL if (gpus[gpu].has_adl) { int engineclock = 0, memclock = 0, activity = 0, fanspeed = 0, fanpercent = 0, powertune = 0; float temp = 0, vddc = 0; if (gpu_stats(gpu, &temp, &engineclock, &memclock, &vddc, &activity, &fanspeed, &fanpercent, &powertune)) { char logline[255]; strcpy(logline, ""); // In case it has no data if (temp != -1) sprintf(logline, "%.1f C ", temp); if (fanspeed != -1 || fanpercent != -1) { tailsprintf(logline, sizeof(logline), "F: "); if (fanpercent != -1) tailsprintf(logline, sizeof(logline), "%d%% ", fanpercent); if (fanspeed != -1) tailsprintf(logline, sizeof(logline), "(%d RPM) ", fanspeed); tailsprintf(logline, sizeof(logline), " "); } if (engineclock != -1) tailsprintf(logline, sizeof(logline), "E: %d MHz ", engineclock); if (memclock != -1) tailsprintf(logline, sizeof(logline), "M: %d Mhz ", memclock); if (vddc != -1) tailsprintf(logline, sizeof(logline), "V: %.3fV ", vddc); if (activity != -1) tailsprintf(logline, sizeof(logline), "A: %d%% ", activity); if (powertune != -1) tailsprintf(logline, sizeof(logline), "P: %d%%", powertune); tailsprintf(logline, sizeof(logline), "\n"); _wlog(logline); } } #endif wlog("Last initialised: %s\n", cgpu->init); wlog("Intensity: "); if (gpus[gpu].dynamic) wlog("Dynamic (only one thread in use)\n"); else wlog("%d\n", gpus[gpu].intensity); for (i = 0; i < mining_threads; i++) { thr = get_thread(i); if (thr->cgpu != cgpu) continue; get_datestamp(checkin, sizeof(checkin), &thr->last); displayed_rolling = thr->rolling; if (!mhash_base) displayed_rolling *= 1000; wlog("Thread %d: %.1f %sh/s %s ", i, displayed_rolling, mhash_base ? "M" : "K" , cgpu->deven != DEV_DISABLED ? "Enabled" : "Disabled"); switch (cgpu->status) { default: case LIFE_WELL: wlog("ALIVE"); break; case LIFE_SICK: wlog("SICK reported in %s", checkin); break; case LIFE_DEAD: wlog("DEAD reported in %s", checkin); break; case LIFE_INIT: case LIFE_NOSTART: wlog("Never started"); break; } if (thr->pause) wlog(" paused"); wlog("\n"); } wlog("\n"); } wlogprint("[E]nable [D]isable [I]ntensity [R]estart GPU %s\n",adl_active ? "[C]hange settings" : ""); wlogprint("Or press any other key to continue\n"); logwin_update(); input = getch(); if (nDevs == 1) selected = 0; else selected = -1; if (!strncasecmp(&input, "e", 1)) { struct cgpu_info *cgpu; if (selected) selected = curses_int("Select GPU to enable"); if (selected < 0 || selected >= nDevs) { wlogprint("Invalid selection\n"); goto retry; } if (gpus[selected].deven != DEV_DISABLED) { wlogprint("Device already enabled\n"); goto retry; } gpus[selected].deven = DEV_ENABLED; for (i = 0; i < mining_threads; ++i) { thr = get_thread(i); cgpu = thr->cgpu; if (cgpu->drv->drv_id != DRIVER_opencl) continue; if (dev_from_id(i) != selected) continue; if (cgpu->status != LIFE_WELL) { wlogprint("Must restart device before enabling it"); goto retry; } applog(LOG_DEBUG, "Pushing sem post to thread %d", thr->id); cgsem_post(&thr->sem); } goto retry; } if (!strncasecmp(&input, "d", 1)) { if (selected) selected = curses_int("Select GPU to disable"); if (selected < 0 || selected >= nDevs) { wlogprint("Invalid selection\n"); goto retry; } if (gpus[selected].deven == DEV_DISABLED) { wlogprint("Device already disabled\n"); goto retry; } gpus[selected].deven = DEV_DISABLED; goto retry; } else if (!strncasecmp(&input, "i", 1)) { int intensity; char *intvar; if (selected) selected = curses_int("Select GPU to change intensity on"); if (selected < 0 || selected >= nDevs) { wlogprint("Invalid selection\n"); goto retry; } if (opt_scrypt) { intvar = curses_input("Set GPU scan intensity (d or " MIN_SCRYPT_INTENSITY_STR " -> " MAX_SCRYPT_INTENSITY_STR ")"); } else { intvar = curses_input("Set GPU scan intensity (d or " MIN_SHA_INTENSITY_STR " -> " MAX_SHA_INTENSITY_STR ")"); } if (!intvar) { wlogprint("Invalid input\n"); goto retry; } if (!strncasecmp(intvar, "d", 1)) { wlogprint("Dynamic mode enabled on gpu %d\n", selected); gpus[selected].dynamic = true; pause_dynamic_threads(selected); free(intvar); goto retry; } intensity = atoi(intvar); free(intvar); if (intensity < MIN_INTENSITY || intensity > MAX_INTENSITY) { wlogprint("Invalid selection\n"); goto retry; } gpus[selected].dynamic = false; gpus[selected].intensity = intensity; wlogprint("Intensity on gpu %d set to %d\n", selected, intensity); pause_dynamic_threads(selected); goto retry; } else if (!strncasecmp(&input, "r", 1)) { if (selected) selected = curses_int("Select GPU to attempt to restart"); if (selected < 0 || selected >= nDevs) { wlogprint("Invalid selection\n"); goto retry; } wlogprint("Attempting to restart threads of GPU %d\n", selected); reinit_device(&gpus[selected]); goto retry; } else if (adl_active && (!strncasecmp(&input, "c", 1))) { if (selected) selected = curses_int("Select GPU to change settings on"); if (selected < 0 || selected >= nDevs) { wlogprint("Invalid selection\n"); goto retry; } change_gpusettings(selected); goto retry; } else clear_logwin(); immedok(logwin, false); opt_loginput = false; }
void thread_cleanup_and_exit (int status) { printf ("%s: exit(%d)\n", thread_name (), status); /* close all open file descriptors */ struct thread *t = thread_current (); struct list_elem *e; /* close all the files opened and free spaces allocated for the file list */ while (!list_empty (&t->file_list)) { e = list_pop_back (&t->file_list); struct file_elem *f_elem = list_entry (e, struct file_elem, elem); file_close (f_elem->file); free (f_elem); } /* free waited_children_list and children_list */ while (!list_empty (&t->children_list)) { e = list_pop_back (&t->children_list); struct child_elem *c_elem = list_entry (e, struct child_elem, elem); // free children from the global exit_list free_thread_from_exit_list (c_elem->pid); free (c_elem); } while (!list_empty (&t->waited_children_list)) { e = list_pop_back (&t->waited_children_list); struct wait_child_elem *w_elem = list_entry (e, struct wait_child_elem, elem); free (w_elem); } /* free mmapped */ while (!list_empty (&t->mmappings)) { e = list_pop_back (&t->mmappings); struct mapid_elem *me = list_entry (e, struct mapid_elem, elem); thread_unmmap_free_pages_of_file (t, me); free (me); } /* Supp Page Table, Swap Table, and Frame Table Free */ spt_free (t->tid); add_thread_to_exited_list (t->tid, status); /* allow file write to executable */ if (t->exec_file) { file_allow_write (t->exec_file); file_close (t->exec_file); } /* release all the locks that have not already been released */ while (!list_empty (&t->acquired_locks)) { struct list_elem *e = list_front (&t->acquired_locks); struct lock *l = list_entry (e, struct lock, elem); lock_release (l); } /* wake parent up if its waiting on it */ struct thread *parent = get_thread (thread_current ()->parent_id); if (parent) { sema_up (&parent->waiting_on_child_exit_sema); } thread_exit (); }
const char * my_thread_name() { thread_t * myself = get_thread(scheduler_running_tid()); return ((myself) ? (myself->name) : (NULL)); }
/* We have only one thread that ever re-initialises GPUs, thus if any GPU * init command fails due to a completely wedged GPU, the thread will never * return, unable to harm other GPUs. If it does return, it means we only had * a soft failure and then the reinit_gpu thread is ready to tackle another * GPU */ void *reinit_gpu(void *userdata) { struct thr_info *mythr = userdata; struct cgpu_info *cgpu; struct thr_info *thr; struct timeval now; char name[256]; int thr_id; int gpu; pthread_detach(pthread_self()); select_cgpu: cgpu = tq_pop(mythr->q, NULL); if (!cgpu) goto out; if (clDevicesNum() != nDevs) { applog(LOG_WARNING, "Hardware not reporting same number of active devices, will not attempt to restart GPU"); goto out; } gpu = cgpu->device_id; for (thr_id = 0; thr_id < mining_threads; ++thr_id) { thr = get_thread(thr_id); cgpu = thr->cgpu; if (cgpu->drv->drv_id != DRIVER_opencl) continue; if (dev_from_id(thr_id) != gpu) continue; thr = get_thread(thr_id); if (!thr) { applog(LOG_WARNING, "No reference to thread %d exists", thr_id); continue; } thr->rolling = thr->cgpu->rolling = 0; /* Reports the last time we tried to revive a sick GPU */ cgtime(&thr->sick); if (!pthread_cancel(thr->pth)) { applog(LOG_WARNING, "Thread %d still exists, killing it off", thr_id); } else applog(LOG_WARNING, "Thread %d no longer exists", thr_id); } for (thr_id = 0; thr_id < mining_threads; ++thr_id) { int virtual_gpu; thr = get_thread(thr_id); cgpu = thr->cgpu; if (cgpu->drv->drv_id != DRIVER_opencl) continue; if (dev_from_id(thr_id) != gpu) continue; virtual_gpu = cgpu->virtual_gpu; /* Lose this ram cause we may get stuck here! */ //tq_freeze(thr->q); thr->q = tq_new(); if (!thr->q) quit(1, "Failed to tq_new in reinit_gpu"); /* Lose this ram cause we may dereference in the dying thread! */ //free(clState); applog(LOG_INFO, "Reinit GPU thread %d", thr_id); clStates[thr_id] = initCl(virtual_gpu, name, sizeof(name)); if (!clStates[thr_id]) { applog(LOG_ERR, "Failed to reinit GPU thread %d", thr_id); goto select_cgpu; } applog(LOG_INFO, "initCl() finished. Found %s", name); if (unlikely(thr_info_create(thr, NULL, miner_thread, thr))) { applog(LOG_ERR, "thread %d create failed", thr_id); return NULL; } applog(LOG_WARNING, "Thread %d restarted", thr_id); } cgtime(&now); get_datestamp(cgpu->init, sizeof(cgpu->init), &now); for (thr_id = 0; thr_id < mining_threads; ++thr_id) { thr = get_thread(thr_id); cgpu = thr->cgpu; if (cgpu->drv->drv_id != DRIVER_opencl) continue; if (dev_from_id(thr_id) != gpu) continue; cgsem_post(&thr->sem); } goto select_cgpu; out: return NULL; }
void nest::pp_pop_psc_delta::calibrate() { if ( P_.tau_eta_.size() == 0 ) throw BadProperty( "Time constant array should not be empty. " ); if ( P_.val_eta_.size() == 0 ) throw BadProperty( "Adaptation value array should not be empty. " ); B_.logger_.init(); V_.h_ = Time::get_resolution().get_ms(); V_.rng_ = kernel().rng_manager.get_rng( get_thread() ); V_.min_double_ = std::numeric_limits< double >::min(); double tau_eta_max = -1; // finding max of tau_eta_ for ( unsigned int j = 0; j < P_.tau_eta_.size(); j++ ) if ( P_.tau_eta_.at( j ) > tau_eta_max ) tau_eta_max = P_.tau_eta_.at( j ); V_.len_eta_ = tau_eta_max * ( P_.len_kernel_ / V_.h_ ); V_.P33_ = std::exp( -V_.h_ / P_.tau_m_ ); V_.P30_ = 1 / P_.c_m_ * ( 1 - V_.P33_ ) * P_.tau_m_; // initializing internal state if ( !S_.initialized_ ) { V_.len_eta_ = tau_eta_max * ( P_.len_kernel_ / V_.h_ ); for ( int j = 0; j < V_.len_eta_; j++ ) S_.n_spikes_past_.push_back( 0 ); std::vector< double > ts; ts.clear(); for ( int j = 0; j < V_.len_eta_; j++ ) ts.push_back( j * V_.h_ ); double temp = 0; for ( int j = 0; j < V_.len_eta_; j++ ) { for ( unsigned int i = 0; i < P_.tau_eta_.size(); i++ ) temp += std::exp( -ts[ j ] / P_.tau_eta_.at( i ) ) * ( -P_.val_eta_.at( i ) ); V_.theta_kernel_.push_back( temp ); V_.eta_kernel_.push_back( std::exp( temp ) - 1 ); temp = 0; } for ( int j = 0; j < V_.len_eta_; j++ ) { S_.age_occupations_.push_back( 0 ); S_.thetas_ages_.push_back( 0 ); S_.n_spikes_ages_.push_back( 0 ); S_.rhos_ages_.push_back( 0 ); } S_.age_occupations_.push_back( P_.N_ ); S_.thetas_ages_.push_back( 0 ); S_.n_spikes_ages_.push_back( 0 ); S_.rhos_ages_.push_back( 0 ); S_.initialized_ = true; } }
// Start main loop int core_loop(void (* server_event)(BSP_CALLBACK *)) { BSP_THREAD *t = get_thread(MAIN_THREAD); if (!t) { trigger_exit(BSP_RTN_FATAL, "Main thread lost!"); } // Servers BSP_VALUE *val = object_get_hash_str(runtime_settings, "servers"); BSP_OBJECT *vobj = value_get_object(val); BSP_STRING *vstr = NULL; if (vobj && OBJECT_TYPE_ARRAY == vobj->type) { struct bsp_conf_server_t srv; BSP_OBJECT *vsrv = NULL; size_t varr_size = object_size(vobj), i; reset_object(vobj); for (i = 0; i < varr_size; i ++) { val = object_get_array(vobj, i); vsrv = value_get_object(val); if (vsrv && OBJECT_TYPE_HASH == vsrv->type) { // Default value memset(&srv, 0, sizeof(struct bsp_conf_server_t)); srv.server_inet = INET_TYPE_ANY; srv.server_sock = SOCK_TYPE_ANY; srv.def_client_type = CLIENT_TYPE_DATA; srv.def_data_type = DATA_TYPE_PACKET; val = object_get_hash_str(vsrv, "name"); vstr = value_get_string(val); srv.server_name = bsp_strndup(STR_STR(vstr), STR_LEN(vstr)); val = object_get_hash_str(vsrv, "inet"); vstr = value_get_string(val); if (vstr) { if (0 == strncasecmp(STR_STR(vstr), "ipv6", 4)) { srv.server_inet = INET_TYPE_IPV6; } else if (0 == strncasecmp(STR_STR(vstr), "ipv4", 4)) { srv.server_inet = INET_TYPE_IPV4; } else if (0 == strncasecmp(STR_STR(vstr), "local", 5)) { srv.server_inet = INET_TYPE_LOCAL; } } val = object_get_hash_str(vsrv, "sock"); vstr = value_get_string(val); if (vstr) { if (0 == strncasecmp(STR_STR(vstr), "tcp", 3)) { srv.server_sock = SOCK_TYPE_TCP; } else if (0 == strncasecmp(STR_STR(vstr), "udp", 3)) { srv.server_sock = SOCK_TYPE_UDP; } } val = object_get_hash_str(vsrv, "addr"); vstr = value_get_string(val); srv.server_addr = bsp_strndup(STR_STR(vstr), STR_LEN(vstr)); val = object_get_hash_str(vsrv, "port"); srv.server_port = (int) value_get_int(val); val = object_get_hash_str(vsrv, "heartbeat_check"); srv.heartbeat_check = (int) value_get_int(val); val = object_get_hash_str(vsrv, "debug_input"); srv.debug_hex_input = value_get_boolean(val); val = object_get_hash_str(vsrv, "debug_output"); srv.debug_hex_input = value_get_boolean(val); val = object_get_hash_str(vsrv, "max_clients"); srv.max_clients = (int) value_get_int(val); val = object_get_hash_str(vsrv, "max_packet_length"); srv.max_packet_length = (size_t) value_get_int(val); val = object_get_hash_str(vsrv, "websocket"); if (value_get_boolean(val)) { srv.def_client_type = CLIENT_TYPE_WEBSOCKET_HANDSHAKE; } val = object_get_hash_str(vsrv, "data_type"); vstr = value_get_string(val); if (vstr && 0 == strncasecmp(STR_STR(vstr), "stream", 6)) { srv.def_data_type = DATA_TYPE_STREAM; } // Add server BSP_SERVER *s; int srv_fds[MAX_SERVER_PER_CREATION], srv_ct, fd_type; int nfds = MAX_SERVER_PER_CREATION; nfds = new_server(srv.server_addr, srv.server_port, srv.server_inet, srv.server_sock, srv_fds, &nfds); for (srv_ct = 0; srv_ct < nfds; srv_ct ++) { fd_type = FD_TYPE_SOCKET_SERVER; s = (BSP_SERVER *) get_fd(srv_fds[srv_ct], &fd_type); if (s) { s->name = srv.server_name; s->heartbeat_check = srv.heartbeat_check; s->def_client_type = srv.def_client_type; s->def_data_type = srv.def_data_type; s->max_packet_length = srv.max_packet_length; s->max_clients = srv.max_clients; s->debug_hex_input = srv.debug_hex_input; s->debug_hex_output = srv.debug_hex_output; add_server(s); } else { bsp_free(srv.server_name); } } } } } // Server event if (server_event) { core_settings.on_srv_events = server_event; } // Create 1 Hz clock BSP_TIMER *tmr = new_timer(BASE_CLOCK_SEC, BASE_CLOCK_USEC, -1); tmr->on_timer = base_timer; core_settings.main_timer = tmr; dispatch_to_thread(tmr->fd, MAIN_THREAD); start_timer(tmr); // Let's go load_bootstrap(); trace_msg(TRACE_LEVEL_CORE, "Core : Main thread loop started"); thread_process((void *) t); return BSP_RTN_SUCCESS; }
uint8_t schedule_thread(uint8_t el_num){ pthread *th = get_thread(el_num); assert_raise_return(th, ERR_VALUE, false); schedule_thread(th); return true; }
void kill_thread(uint8_t el_num){ pthread *th = get_thread(el_num); assert_raise_return(th, ERR_VALUE); kill_thread(th); }
static int find_thread_link (const char * name, struct shim_qstr * link, struct shim_dentry ** dentptr, struct shim_thread ** threadptr) { const char * next, * nextnext; int next_len; int pid = parse_thread_name(name, &next, &next_len, &nextnext); if (pid < 0) return pid; struct shim_thread * thread = lookup_thread(pid); struct shim_dentry * dent = NULL; int ret = 0; if (!thread) return -ENOENT; if (!thread->in_vm) { ret = -ENOENT; goto out; } lock(&thread->lock); if (next_len == static_strlen("root") && !memcmp(next, "root", next_len)) { dent = thread->root; get_dentry(dent); } if (next_len == static_strlen("cwd") && !memcmp(next, "cwd", next_len)) { dent = thread->cwd; get_dentry(dent); } if (next_len == static_strlen("exe") && !memcmp(next, "exe", next_len)) { struct shim_handle * exec = thread->exec; if (!exec->dentry) { unlock(&thread->lock); ret = -EINVAL; goto out; } dent = exec->dentry; get_dentry(dent); } unlock(&thread->lock); if (nextnext) { struct shim_dentry * next_dent = NULL; ret = path_lookupat(dent, nextnext, 0, &next_dent, dent->fs); if (ret < 0) goto out; put_dentry(dent); dent = next_dent; } if (link) { int size; char * path = dentry_get_path(dent, true, &size); qstrsetstr(link, path, size); } if (dentptr) { get_dentry(dent); *dentptr = dent; } if (threadptr) { get_thread(thread); *threadptr = thread; } ret = 0; out: if (dent) put_dentry(dent); if (thread) put_thread(thread); return ret; }
void LIR_Assembler::emit_op0(LIR_Op0* op) { switch (op->code()) { case lir_word_align: { while (code_offset() % BytesPerWord != 0) { _masm->nop(); } break; } case lir_nop: assert(op->info() == NULL, "not supported"); _masm->nop(); break; case lir_label: Unimplemented(); break; case lir_build_frame: build_frame(); break; case lir_std_entry: // init offsets offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset()); _masm->align(CodeEntryAlignment); if (needs_icache(compilation()->method())) { check_icache(); } offsets()->set_value(CodeOffsets::Verified_Entry, _masm->offset()); _masm->verified_entry(); build_frame(); offsets()->set_value(CodeOffsets::Frame_Complete, _masm->offset()); break; case lir_osr_entry: offsets()->set_value(CodeOffsets::OSR_Entry, _masm->offset()); osr_entry(); break; case lir_24bit_FPU: set_24bit_FPU(); break; case lir_reset_FPU: reset_FPU(); break; case lir_breakpoint: breakpoint(); break; case lir_fpop_raw: fpop(); break; case lir_membar: membar(); break; case lir_membar_acquire: membar_acquire(); break; case lir_membar_release: membar_release(); break; case lir_membar_loadload: membar_loadload(); break; case lir_membar_storestore: membar_storestore(); break; case lir_membar_loadstore: membar_loadstore(); break; case lir_membar_storeload: membar_storeload(); break; case lir_get_thread: get_thread(op->result_opr()); break; default: ShouldNotReachHere(); break; } }
PUBLIC static void Jdb::get_current(Cpu_number cpu) { current_active = get_thread(cpu); }
void nest::poisson_generator_ps::event_hook( DSSpikeEvent& e ) { // get port number const port prt = e.get_port(); // we handle only one port here, get reference to vector elem assert( 0 <= prt && static_cast< size_t >( prt ) < B_.next_spike_.size() ); // obtain rng librandom::RngPtr rng = kernel().rng_manager.get_rng( get_thread() ); // introduce nextspk as a shorthand Buffers_::SpikeTime& nextspk = B_.next_spike_[ prt ]; if ( nextspk.first.is_neg_inf() ) { // need to initialize relative to t_min_active_ // first spike is drawn from backward recurrence time to initialize the process in equilibrium. // In the case of the Poisson process with dead time, this has two domains: // one with uniform probability (t<dead_time) and one // with exponential probability (t>=dead_time). // First we draw a uniform number to choose the case according to the associated probability // mass. // If dead_time==0 we do not want to draw addtional random numbers (keeps old functionality). double spike_offset = 0; if ( P_.dead_time_ > 0 and rng->drand() < P_.dead_time_ * P_.rate_ / 1000.0 ) { // uniform case: spike occurs with uniform probability in [0, dead_time]. spike_offset = rng->drand() * P_.dead_time_; } else { // exponential case: spike occurs with exponential probability in [dead_time, infinity] spike_offset = V_.inv_rate_ms_ * V_.exp_dev_( rng ) + P_.dead_time_; } // spike_offset is now time from t_min_active_ til first spike. // Split into stamp+offset, then add t_min_active. nextspk.first = Time::ms_stamp( spike_offset ); nextspk.second = nextspk.first.get_ms() - spike_offset; nextspk.first += V_.t_min_active_; } // as long as there are spikes in active period, emit and redraw while ( nextspk.first <= V_.t_max_active_ ) { // std::cerr << nextspk.first << '\t' << nextspk.second << '\n'; e.set_stamp( nextspk.first ); e.set_offset( nextspk.second ); e.get_receiver().handle( e ); // Draw time of next spike // Time of spike relative to current nextspk.first stamp const double new_offset = -nextspk.second + V_.inv_rate_ms_ * V_.exp_dev_( rng ) + P_.dead_time_; if ( new_offset < 0 ) // still in same stamp nextspk.second = -new_offset; // stamps always 0 < stamp <= h else { // split into stamp and offset, then add to old stamp const Time delta_stamp = Time::ms_stamp( new_offset ); nextspk.first += delta_stamp; nextspk.second = delta_stamp.get_ms() - new_offset; } } // std::cerr << "********************************\n"; }
void IzhikevichBranch::calibrate() { B_.logger_.init(); V_.rng_ = net_->get_rng( get_thread() ); }