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  SubsystemType { Posix = 0, Native = 1, None = 255 }
 
enum  KillReason { Interrupted = 0, Terminated = 1, Unknown = 255 }
 
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, Other = 255
}
 

Public Member Functions

 Subsystem ()
 
 Subsystem (const Subsystem &s)
 
 Subsystem (SubsystemType type)
 
virtual ~Subsystem ()
 
virtual void acquire ()
 Acquire full mutual exclusion for all Subsystem resources. More...
 
virtual void release ()
 
virtual void exit (int code)=0
 
virtual bool kill (KillReason killReason, Thread *pThread=0)=0
 
virtual void threadException (Thread *pThread, ExceptionType eType)
 
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
 
virtual FilefindFile (const String &path, File *workingDir)=0
 

Protected Member Functions

virtual void threadRemoved (Thread *pThread)
 

Protected Attributes

SubsystemType m_Type
 
Processm_pProcess
 

Private Member Functions

const Subsystemoperator= (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 42 of file Subsystem.h.

Member Enumeration Documentation

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 67 of file Subsystem.h.

Reason for kill()

Definition at line 56 of file Subsystem.h.

Defines the different types of subsystems

Definition at line 48 of file Subsystem.h.

Constructor & Destructor Documentation

Subsystem::Subsystem ( )
inline

Default constructor

Definition at line 87 of file Subsystem.h.

Subsystem::Subsystem ( const Subsystem s)
inline

Copy constructor

Definition at line 92 of file Subsystem.h.

Subsystem::Subsystem ( SubsystemType  type)
inline

Parameterised constructor

Definition at line 97 of file Subsystem.h.

References Process::kill().

Subsystem::~Subsystem ( )
virtualdefault

Default destructor

Member Function Documentation

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:

virtual void Subsystem::exit ( int  code)
pure virtual

Need to exit this process.

Implemented in PosixSubsystem.

Referenced by PerProcessorScheduler::timer().

+ Here is the caller graph for this function:

virtual File* Subsystem::findFile ( const String path,
File workingDir 
)
pure virtual

Finds a file, performing any subsystem-specific logic as needed.

Implemented in PosixSubsystem.

SubsystemType Subsystem::getType ( )
inline

Gets the type of this subsystem

Definition at line 131 of file Subsystem.h.

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

Invokes the given command (thread mechanism).

Implemented in PosixSubsystem.

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.

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.

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.

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(), and WaitCleanup::terminated().

+ Here is the caller graph for this function:

void Subsystem::release ( )
virtual

Release mutual exclusion acquired via acquire().

Reimplemented in PosixSubsystem.

Definition at line 30 of file Subsystem.cc.

virtual void Subsystem::setProcess ( Process p)
inlinevirtual

Sets the process that this subsystem is linked to.

Definition at line 137 of file Subsystem.h.

References WARNING.

Referenced by Process::getEffectiveGroup().

+ Here is the caller graph for this function:

void Subsystem::threadException ( Thread pThread,
ExceptionType  eType 
)
virtual

A thread has thrown an exception!

Reimplemented in PosixSubsystem.

Definition at line 35 of file Subsystem.cc.

References ERROR.

Referenced by PosixSubsystem::exit(), HostedInterruptManager::interrupt(), X64InterruptManager::interrupt(), X86InterruptManager::interrupt(), and Process::suspend().

+ Here is the caller graph for this function:

virtual void Subsystem::threadRemoved ( Thread pThread)
inlineprotectedvirtual

Notifies the subsystem that the given thread has been removed.

Reimplemented in PosixSubsystem.

Definition at line 170 of file Subsystem.h.

Referenced by Process::removeThread().

+ Here is the caller graph for this function:


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