mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:12:45 +00:00 
			
		
		
		
	Implement a basic way for read() to block.
FileHandle gets a hasDataAvailableForRead() getter. If this returns true in sys$read(), the task will block(BlockedRead) + yield. The fd blocked on is stored in Task::m_fdBlockedOnRead. The scheduler then looks at the state of that fd during the unblock phase. This makes "sh" restful. :^) There's still some problem with the kernel not surviving the colonel task getting scheduled. I need to figure that out and fix it.
This commit is contained in:
		
							parent
							
								
									ba56f4afde
								
							
						
					
					
						commit
						c6f2890d8e
					
				
					 18 changed files with 86 additions and 17 deletions
				
			
		|  | @ -12,6 +12,8 @@ public: | |||
|     Unix::ssize_t read(byte* buffer, Unix::size_t count); | ||||
|     int stat(Unix::stat*); | ||||
| 
 | ||||
|     bool hasDataAvailableForRead(); | ||||
| 
 | ||||
|     ssize_t get_dir_entries(byte* buffer, Unix::size_t); | ||||
| 
 | ||||
|     ByteBuffer readEntireFile(); | ||||
|  | @ -21,6 +23,9 @@ public: | |||
| #ifdef SERENITY | ||||
|     int fd() const { return m_fd; } | ||||
|     void setFD(int fd) { m_fd = fd; } | ||||
| 
 | ||||
|     bool isBlocking() const { return m_isBlocking; } | ||||
|     void setBlocking(bool b) { m_isBlocking = b; } | ||||
| #endif | ||||
| 
 | ||||
| private: | ||||
|  | @ -32,6 +37,7 @@ private: | |||
| 
 | ||||
| #ifdef SERENITY | ||||
|     int m_fd { -1 }; | ||||
|     bool m_isBlocking { true }; | ||||
| #endif | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling