![]() |
Max OS 0.3
|
The execution context of a sub-process thread. More...
#include <process.h>
Public Member Functions | |
| Thread (void(*_entry_point)(void *), void *args, int arg_amount, Process *parent) | |
| Constructor for the Thread class. | |
| ~Thread () | |
| Destructor for the Thread class. | |
| void | sleep (size_t milliseconds) |
| Sleeps the thread for a certain amount of time. | |
| void | yield () |
| Pass execution to the next ready thread. | |
| uintptr_t | tss_pointer () const |
| Gets the stack pointer to use for the TSS when switching to this thread. | |
| void | set_tss_pointer (uintptr_t new_tss_pointer) |
| Sets the stack pointer to use for the TSS when switching to this thread. | |
| void | save_sse_state () |
| Saves the SSE, x87 FPU, and MMX states from memory to the thread. | |
| void | restore_sse_state () |
| Restores the SSE, x87 FPU, and MMX states from the thread to memory. | |
| void | save_cpu_state () |
| Saves the CPU state into the thread's execution_state structure. | |
| void | enable_port (uint64_t port) |
| Sets bits in the threads TSS to allow a port for I/O. | |
| void | disable_port (uint64_t port) |
| Sets bits in the threads TSS to disallow a port for I/O. | |
| void | load_port_bitmap () |
| Copy this ports. | |
Public Attributes | |
| uint64_t | tid |
| The thread ID. | |
| uint64_t | parent_pid |
| The parent process ID. | |
| volatile system::cpu_status_t | execution_state |
| The CPU state of the thread. | |
| volatile thread_state_t | thread_state |
| The current state of the thread. | |
| volatile size_t | ticks |
| The number of ticks the thread has run for. | |
| volatile size_t | wakeup_time |
| The time at which the thread should wake up (if sleeping) | |
The execution context of a sub-process thread.
| Thread::Thread | ( | void(*)(void *) | _entry_point, |
| void * | args, | ||
| int | arg_amount, | ||
| Process * | parent | ||
| ) |
Constructor for the Thread class.
| _entry_point | The address of the function to start executing |
| args | The arguments to pass to the function |
| arg_amount | The number of arguments |
| parent | The proccess that owns this thread (started it) |
Definition at line 32 of file process.cpp.
References MaxOS::memory::allocator::BumpAllocator::allocate(), MaxOS::system::CPU::executing_core(), execution_state, MaxOS::processes::Process::is_kernel, MaxOS::memory::MemoryManager::kmalloc(), MaxOS::processes::Process::memory_manager, parent_pid, MaxOS::processes::Process::pid(), MaxOS::processes::STACK_SIZE, thread_state, ticks, and wakeup_time.
| void Thread::disable_port | ( | uint64_t | port | ) |
Sets bits in the threads TSS to disallow a port for I/O.
Definition at line 258 of file process.cpp.
References load_port_bitmap().
Referenced by MaxOS::processes::resources::ThreadResource::write().
| void Thread::enable_port | ( | uint64_t | port | ) |
Sets bits in the threads TSS to allow a port for I/O.
Definition at line 247 of file process.cpp.
References load_port_bitmap().
Referenced by MaxOS::processes::resources::ThreadResource::write().
| void Thread::load_port_bitmap | ( | ) |
Copy this ports.
Definition at line 268 of file process.cpp.
References MaxOS::system::CPU::executing_core().
Referenced by disable_port(), and enable_port().
| void Thread::restore_sse_state | ( | ) |
Restores the SSE, x87 FPU, and MMX states from the thread to memory.
Definition at line 138 of file process.cpp.
References MaxOS::system::CPU::executing_core().
| void Thread::save_cpu_state | ( | ) |
Saves the CPU state into the thread's execution_state structure.
Definition at line 240 of file process.cpp.
References execution_state, and save_cpu_state_naked().
Referenced by yield().
| void Thread::save_sse_state | ( | ) |
Saves the SSE, x87 FPU, and MMX states from memory to the thread.
Definition at line 125 of file process.cpp.
References MaxOS::system::CPU::executing_core().
Referenced by MaxOS::processes::Scheduler::schedule_next().
|
inline |
| void Thread::sleep | ( | size_t | milliseconds | ) |
Sleeps the thread for a certain amount of time.
| milliseconds | The amount of time to sleep for |
Definition at line 92 of file process.cpp.
References thread_state, wakeup_time, and yield().
Referenced by MaxOS::processes::resources::ThreadResource::write().
|
inline |
| void Thread::yield | ( | ) |
Pass execution to the next ready thread.
Definition at line 103 of file process.cpp.
References MaxOS::processes::GlobalScheduler::core_scheduler(), execution_state, MaxOS::hardwarecommunication::InterruptManager::ForceInterruptReturn(), save_cpu_state(), MaxOS::processes::Scheduler::schedule_next(), and thread_state.
Referenced by MaxOS::runtime::TrapFlagExcpetion::handle_interrupt(), MaxOS::runtime::BreakPointException::handle_interrupt(), MaxOS::processes::SharedMessageEndpoint::read(), MaxOS::processes::resources::BridgeHandler::send_to_bridge(), sleep(), and MaxOS::processes::resources::ThreadResource::write().
| volatile system::cpu_status_t MaxOS::processes::Thread::execution_state |
The CPU state of the thread.
Definition at line 71 of file process.h.
Referenced by MaxOS::runtime::GDBServer::attach(), MaxOS::runtime::GDBServer::handle_step_instruction(), save_cpu_state(), MaxOS::processes::Scheduler::schedule_next(), Thread(), and yield().
| uint64_t MaxOS::processes::Thread::parent_pid |
The parent process ID.
Definition at line 69 of file process.h.
Referenced by MaxOS::processes::Process::add_thread(), MaxOS::processes::Scheduler::current_process(), MaxOS::runtime::GDBServer::handle_remove_breakpoint(), MaxOS::runtime::GDBServer::handle_set_breakpoint(), MaxOS::processes::resources::ThreadResource::read(), MaxOS::processes::Scheduler::schedule_next(), MaxOS::runtime::GDBServer::send_memory(), and Thread().
| volatile thread_state_t MaxOS::processes::Thread::thread_state |
The current state of the thread.
Definition at line 72 of file process.h.
Referenced by MaxOS::runtime::GDBServer::attach(), MaxOS::processes::resources::ThreadResource::close(), MaxOS::runtime::GDBServer::handle_continue(), MaxOS::runtime::GDBServer::handle_detach(), MaxOS::runtime::TrapFlagExcpetion::handle_interrupt(), MaxOS::runtime::BreakPointException::handle_interrupt(), MaxOS::runtime::GDBServer::handle_step_instruction(), MaxOS::processes::resources::ThreadResource::read(), MaxOS::processes::BlockingLock::release(), MaxOS::processes::Scheduler::remove_process(), MaxOS::processes::Scheduler::schedule_next(), sleep(), Thread(), MaxOS::processes::resources::ThreadResource::write(), and yield().
| volatile size_t MaxOS::processes::Thread::ticks |
The number of ticks the thread has run for.
Definition at line 74 of file process.h.
Referenced by MaxOS::processes::resources::ThreadResource::read(), MaxOS::processes::Scheduler::schedule(), and Thread().
| uint64_t MaxOS::processes::Thread::tid |
The thread ID.
Definition at line 68 of file process.h.
Referenced by MaxOS::processes::Scheduler::add_process(), MaxOS::processes::Scheduler::add_thread(), MaxOS::processes::Scheduler::force_remove_process(), MaxOS::processes::Scheduler::get_thread(), MaxOS::processes::resources::ThreadResource::read(), and MaxOS::processes::Scheduler::schedule_next().
| volatile size_t MaxOS::processes::Thread::wakeup_time |
The time at which the thread should wake up (if sleeping)
Definition at line 75 of file process.h.
Referenced by MaxOS::processes::resources::ThreadResource::read(), MaxOS::processes::Scheduler::schedule_next(), sleep(), and Thread().