The Pedigree Project 0.1
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
Subsystem Class Referenceabstract

#include <Subsystem.h>

+ Inheritance diagram for Subsystem:
+ Collaboration diagram for Subsystem:

Public Types

enum class  UserReturnResult { Continue , Terminal }
 
enum class  UserReturnEventResult { Deliver , Consumed , Terminal }
 
enum  SubsystemType { Posix = 0 , Native = 1 , None = 255 }
 
enum  KillReason { Interrupted = 0 , Terminated = 1 , Unknown = 255 }
 
enum class  ExitCause { Normal , Signal }
 
enum  ExceptionType {
  InvalidOpcode = 0 , PageFault = 1 , GeneralProtectionFault = 2 , DivideByZero = 3 ,
  FpuError = 4 , SpecialFpuError = 5 , TerminalInput = 6 , TerminalOutput = 7 ,
  Continue = 8 , Stop = 9 , Interrupt = 10 , Quit = 11 ,
  Child = 12 , Pipe = 13 , FileMappingFault = 14 , Other = 255
}
 

Public Member Functions

virtual UserReturnResult userReturnCheckpoint (Thread &, UserReturnFrame &)
 
virtual UserReturnEventResult userReturnEvent (Thread &, Event &, UserReturnFrame &)
 
 Subsystem ()
 
 Subsystem (const Subsystem &s)
 
 Subsystem (SubsystemType type)
 
virtual ~Subsystem ()
 
virtual void acquire ()
 Acquire full mutual exclusion for all Subsystem resources.
 
virtual void release ()
 
virtual void exit (int code, ExitCause cause=ExitCause::Normal)=0
 
virtual bool kill (KillReason killReason, Thread *pThread=0)=0
 
virtual void threadException (Thread *pThread, ExceptionType eType, InterruptState *pState=nullptr, uintptr_t faultAddress=0, uintptr_t errorCode=0)
 
virtual bool resolveUserPageFault (Thread &, InterruptState &, uintptr_t, uintptr_t)
 
SubsystemType getType ()
 
virtual void setProcess (Process *p)
 
virtual bool invoke (const char *name, Vector< String > &argv, Vector< String > &env)=0
 
virtual bool invoke (const char *name, Vector< String > &argv, Vector< String > &env, SyscallState &state)=0
 
virtual bool invoke (File *originalFile, const String &originalName, Vector< String > &argv, Vector< String > &env)=0
 
virtual bool invoke (File *originalFile, const String &originalName, Vector< String > &argv, Vector< String > &env, SyscallState &state)=0
 

Protected Member Functions

virtual void prepareThreadsForExec (Thread *owner)
 
virtual void preserveProcessSignalsForThreadExit (Thread *thread)
 
virtual void threadExiting (Thread *pThread)
 
virtual void threadRemoved (Thread *pThread)
 

Protected Attributes

SubsystemType m_Type
 
Process * m_pProcess
 

Private Member Functions

const Subsystem & operator= (const Subsystem &)
 

Friends

class Process
 

Detailed Description

The abstract base class for a generic application subsystem. This provides a well-defined interface to the kernel that allows global behaviour to have correct results on different applications. This also allows the kernel to keep subsystem-specific code to a minimum.

Basically, when inheriting from this class, you are creating a layer between your subsystem and the kernel.

Definition at line 44 of file Subsystem.h.

Member Enumeration Documentation

◆ ExceptionType

Type of exception. This is passed to the subsystem when a Thread throws an exception, which allows subsystem-specific behaviour to be performed.

Definition at line 70 of file Subsystem.h.

◆ ExitCause

enum class Subsystem::ExitCause
strong

How a process reached its terminal state.

Definition at line 64 of file Subsystem.h.

◆ KillReason

Reason for kill()

Definition at line 61 of file Subsystem.h.

◆ SubsystemType

Defines the different types of subsystems

Definition at line 58 of file Subsystem.h.

◆ UserReturnEventResult

enum class Subsystem::UserReturnEventResult
strong

Definition at line 49 of file Subsystem.h.

◆ UserReturnResult

enum class Subsystem::UserReturnResult
strong

Definition at line 48 of file Subsystem.h.

Constructor & Destructor Documentation

◆ Subsystem() [1/3]

Subsystem::Subsystem ( )
inline

Default constructor

Definition at line 90 of file Subsystem.h.

◆ Subsystem() [2/3]

Subsystem::Subsystem ( const Subsystem &  s)
inline

Copy constructor

Definition at line 93 of file Subsystem.h.

◆ Subsystem() [3/3]

Subsystem::Subsystem ( SubsystemType  type)
inline

Parameterised constructor

Definition at line 96 of file Subsystem.h.

◆ ~Subsystem()

Subsystem::~Subsystem ( )
virtualdefault

Default destructor

Member Function Documentation

◆ acquire()

void Subsystem::acquire ( )
virtual

Acquire full mutual exclusion for all Subsystem resources.

It is sometimes necessary to perform an operation that would require the entire Subsystem to be owned by a specific thread. For example, Subsystem termination often requires all other threads to exit the Subsystem's critical sections before it can complete.

This call allows that thread to acquire that mutual exclusion.

Reimplemented in PosixSubsystem.

Definition at line 25 of file Subsystem.cc.

Referenced by Process::~Process().

+ Here is the caller graph for this function:

◆ exit()

virtual void Subsystem::exit ( int  code,
ExitCause  cause = ExitCause::Normal 
)
pure virtual

Need to exit this process.

Implemented in PosixSubsystem.

Referenced by PerProcessorScheduler::commitUserReturnTerminalState(), X64SyscallManager::syscall(), and Thread::threadExited().

+ Here is the caller graph for this function:

◆ getType()

SubsystemType Subsystem::getType ( )
inline

Gets the type of this subsystem

Definition at line 140 of file Subsystem.h.

◆ invoke() [1/4]

virtual bool Subsystem::invoke ( const char *  name,
Vector< String > &  argv,
Vector< String > &  env 
)
pure virtual

Invokes the given command (thread mechanism).

Implemented in PosixSubsystem.

◆ invoke() [2/4]

virtual bool Subsystem::invoke ( const char *  name,
Vector< String > &  argv,
Vector< String > &  env,
SyscallState &  state 
)
pure virtual

Invokes the given command (SyscallState mechanism).

Implemented in PosixSubsystem.

◆ invoke() [3/4]

virtual bool Subsystem::invoke ( File *  originalFile,
const String &  originalName,
Vector< String > &  argv,
Vector< String > &  env 
)
pure virtual

Invokes the given file (thread mechanism).

Implemented in PosixSubsystem.

◆ invoke() [4/4]

virtual bool Subsystem::invoke ( File *  originalFile,
const String &  originalName,
Vector< String > &  argv,
Vector< String > &  env,
SyscallState &  state 
)
pure virtual

Invokes the given file (SyscallState mechanism).

Implemented in PosixSubsystem.

◆ kill()

virtual bool Subsystem::kill ( KillReason  killReason,
Thread *  pThread = 0 
)
pure virtual

A thread (or process, depending on implementation) needs to be killed! This must block until the thread/process ceases to exist.

Implemented in PosixSubsystem.

Referenced by MemoryPressureProcessKiller::compact().

+ Here is the caller graph for this function:

◆ prepareThreadsForExec()

virtual void Subsystem::prepareThreadsForExec ( Thread *  owner)
inlineprotectedvirtual

Preserves process state after exec admission closes and before peers exit.

Reimplemented in PosixSubsystem.

Definition at line 169 of file Subsystem.h.

◆ preserveProcessSignalsForThreadExit()

virtual void Subsystem::preserveProcessSignalsForThreadExit ( Thread *  thread)
inlineprotectedvirtual

Preserves process-owned pending work before an exiting thread drains it.

Reimplemented in PosixSubsystem.

Definition at line 172 of file Subsystem.h.

Referenced by Process::transferExecProcessSignals().

+ Here is the caller graph for this function:

◆ release()

void Subsystem::release ( )
virtual

Release mutual exclusion acquired via acquire().

Reimplemented in PosixSubsystem.

Definition at line 29 of file Subsystem.cc.

◆ resolveUserPageFault()

virtual bool Subsystem::resolveUserPageFault ( Thread &  ,
InterruptState &  ,
uintptr_t  ,
uintptr_t   
)
inlinevirtual

Retry a userspace page fault after raw interrupt scopes have retired.

Reimplemented in PosixSubsystem.

Definition at line 135 of file Subsystem.h.

Referenced by PerProcessorScheduler::serviceDeferredSubsystemException().

+ Here is the caller graph for this function:

◆ setProcess()

virtual void Subsystem::setProcess ( Process *  p)
inlinevirtual

Sets the process that this subsystem is linked to.

Reimplemented in PosixSubsystem.

Definition at line 145 of file Subsystem.h.

Referenced by PosixSubsystem::setProcess().

+ Here is the caller graph for this function:

◆ threadException()

void Subsystem::threadException ( Thread *  pThread,
ExceptionType  eType,
InterruptState *  pState = nullptr,
uintptr_t  faultAddress = 0,
uintptr_t  errorCode = 0 
)
virtual

A thread has thrown an exception.

The interrupt state is borrowed for this call only. Architecture-neutral and synthetic exceptions may omit the optional machine context.

Reimplemented in PosixSubsystem.

Definition at line 33 of file Subsystem.cc.

Referenced by Process::publishTerminationStatus(), PerProcessorScheduler::serviceDeferredSubsystemException(), and Process::suspendInternal().

+ Here is the caller graph for this function:

◆ threadExiting()

virtual void Subsystem::threadExiting ( Thread *  pThread)
inlineprotectedvirtual

Notifies the subsystem immediately before a thread announces exit.

Reimplemented in PosixSubsystem.

Definition at line 175 of file Subsystem.h.

Referenced by Process::threadExiting().

+ Here is the caller graph for this function:

◆ threadRemoved()

virtual void Subsystem::threadRemoved ( Thread *  pThread)
inlineprotectedvirtual

Notifies the subsystem that the given thread has been removed.

Reimplemented in PosixSubsystem.

Definition at line 178 of file Subsystem.h.

Referenced by Process::removeThread().

+ Here is the caller graph for this function:

◆ userReturnCheckpoint()

virtual UserReturnResult Subsystem::userReturnCheckpoint ( Thread &  ,
UserReturnFrame &   
)
inlinevirtual

Definition at line 50 of file Subsystem.h.

◆ userReturnEvent()

virtual UserReturnEventResult Subsystem::userReturnEvent ( Thread &  ,
Event &  ,
UserReturnFrame &   
)
inlinevirtual

Definition at line 53 of file Subsystem.h.

Friends And Related Symbol Documentation

◆ Process

friend class Process
friend

Definition at line 45 of file Subsystem.h.

Member Data Documentation

◆ m_pProcess

Process* Subsystem::m_pProcess
protected

Definition at line 182 of file Subsystem.h.

◆ m_Type

SubsystemType Subsystem::m_Type
protected

Definition at line 180 of file Subsystem.h.


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