uThreads  0.3.0
Public Member Functions | Static Public Member Functions | Friends | List of all members
kThread Class Reference

Object to represent kernel threads. More...

#include <kThread.h>

Inheritance diagram for kThread:
Inheritance graph
[legend]
Collaboration diagram for kThread:
Collaboration graph
[legend]

Public Member Functions

 kThread (Cluster &)
 Create a kThread on the passed cluster. More...
 
 kThread (const kThread &)=delete
 kThread cannot be copied or assigned.
 
const kThreadoperator= (const kThread &)=delete
 kThread cannot be copied or assigned. More...
 
std::thread::native_handle_type getThreadNativeHandle ()
 return the native hanlde for the kernel thread More...
 
std::thread::id getID ()
 returns the kernel thread ID More...
 

Static Public Member Functions

static kThreadcurrentkThread ()
 Get the pointer to the current kThread. More...
 
static uint getTotalNumberOfkThreads ()
 

Friends

class uThread
 
class Cluster
 
class IOHandler
 
class Scheduler
 

Detailed Description

Object to represent kernel threads.

kThread is an interface for underlying kernel threads. kThreads are pulling and pushing uThreads from ReadyQueue provided by the Cluster and context switch to them and execute them. Each kThread belongs to only and only one Cluster and it can only pull uThreads from the ReadyQueue of that Cluster. However, kThreads can push uThreads to the ReadyQueue of any cluster.

defaultKT is the first kernel thread that executes and is responsible for running the main() function. defaultKT is created when the program starts.

Each kThread has a mainUT which is a uThread used when the ReadyQueue is empty. mainUT is used to switch out the previous uThread and either pull uThreads from the ReadyQueue if it's not empty, or block on a condition variable waiting for uThreads to be pushed to the queue.

kThreads can be created by passing a Cluster to the constructor of the kThread.

Constructor & Destructor Documentation

kThread::kThread ( Cluster cluster)

Create a kThread on the passed cluster.

Parameters
TheCluster this kThread belongs to.

Member Function Documentation

static kThread* kThread::currentkThread ( )
inlinestatic

Get the pointer to the current kThread.

Returns
current kThread

This is necessary when a uThread wants to find which kThread it is being executed over.

std::thread::id kThread::getID ( )

returns the kernel thread ID

Returns
the kThread ID

The returned type depends on the platform.

std::thread::native_handle_type kThread::getThreadNativeHandle ( )

return the native hanlde for the kernel thread

Returns
native handle for the kThread

In linux this is pthread_t representation of the thread.

static uint kThread::getTotalNumberOfkThreads ( )
inlinestatic
Returns
total number of kThreads running under the program.
const kThread& kThread::operator= ( const kThread )
delete

kThread cannot be copied or assigned.


The documentation for this class was generated from the following files: