Allow a remote affinity event in a running thread
This commit is contained in:
		
							parent
							
								
									aa3607f744
								
							
						
					
					
						commit
						a7c03179db
					
				
							
								
								
									
										24
									
								
								emu_ovni.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								emu_ovni.c
									
									
									
									
									
								
							| @ -213,15 +213,31 @@ ev_affinity_remote(struct ovni_emu *emu) | |||||||
| 	thread = emu_get_thread(emu, tid); | 	thread = emu_get_thread(emu, tid); | ||||||
| 
 | 
 | ||||||
| 	assert(thread); | 	assert(thread); | ||||||
| 	assert(thread->state == TH_ST_PAUSED); | 
 | ||||||
|  | 	/* The thread may still be running */ | ||||||
|  | 	assert(thread->state == TH_ST_RUNNING || | ||||||
|  | 			thread->state == TH_ST_PAUSED); | ||||||
|  | 
 | ||||||
|  | 	/* It must have an assigned CPU */ | ||||||
| 	assert(thread->cpu); | 	assert(thread->cpu); | ||||||
| 
 | 
 | ||||||
|  | 	/* Migrate current cpu to the one at cpuid */ | ||||||
| 	newcpu = emu_get_cpu(emu->cur_loom, cpuid); | 	newcpu = emu_get_cpu(emu->cur_loom, cpuid); | ||||||
| 
 | 
 | ||||||
| 	/* It must not be running in any of the cpus */ | 	/* If running, update the CPU thread lists */ | ||||||
| 	assert(emu_cpu_find_thread(thread->cpu, thread) == -1); | 	if(thread->state == TH_ST_RUNNING) | ||||||
| 	assert(emu_cpu_find_thread(newcpu, thread) == -1); | 	{ | ||||||
|  | 		emu_cpu_remove_thread(thread->cpu, thread); | ||||||
|  | 		emu_cpu_add_thread(newcpu, thread); | ||||||
|  | 	} | ||||||
|  | 	else | ||||||
|  | 	{ | ||||||
|  | 		/* Otherwise, ensure that it is not in any CPU list */ | ||||||
|  | 		assert(emu_cpu_find_thread(thread->cpu, thread) == -1); | ||||||
|  | 		assert(emu_cpu_find_thread(newcpu, thread) == -1); | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/* Always set the assigned CPU in the thread */ | ||||||
| 	thread->cpu = newcpu; | 	thread->cpu = newcpu; | ||||||
| 
 | 
 | ||||||
| 	//dbg("thread %d switches to cpu %d by remote petition\n", tid,
 | 	//dbg("thread %d switches to cpu %d by remote petition\n", tid,
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user