forked from Bananymous/banan-os
				
			Kernel: Scheduler can now block threads based on tid
This commit is contained in:
		
							parent
							
								
									57798e5d76
								
							
						
					
					
						commit
						be47743dfa
					
				| 
						 | 
					@ -26,6 +26,7 @@ namespace Kernel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void block_current_thread(Semaphore*);
 | 
							void block_current_thread(Semaphore*);
 | 
				
			||||||
		void unblock_threads(Semaphore*);
 | 
							void unblock_threads(Semaphore*);
 | 
				
			||||||
 | 
							void unblock_thread(pid_t tid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Thread& current_thread();
 | 
							Thread& current_thread();
 | 
				
			||||||
		static pid_t current_tid();
 | 
							static pid_t current_tid();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -351,7 +351,26 @@ namespace Kernel
 | 
				
			||||||
				it++;
 | 
									it++;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void Scheduler::unblock_thread(pid_t tid)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							CriticalScope _;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (auto it = m_blocking_threads.begin(); it != m_blocking_threads.end(); it++)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (it->thread->tid() == tid)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									auto thread = it->thread;
 | 
				
			||||||
 | 
									it = m_blocking_threads.remove(it);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									// This should work as we released enough memory from active thread
 | 
				
			||||||
 | 
									static_assert(sizeof(ActiveThread) == sizeof(BlockingThread));
 | 
				
			||||||
 | 
									MUST(m_active_threads.emplace_back(thread));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									return;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue