Documentation ¶
Overview ¶
Package hivemind implements the TreadMarks API.
This file contains the API and the top level handlers for the HiveMind DSM ¶
Package hivemind implements the TreadMarks API.
This file contains the implementation of the IntervalRecord ¶
Package hivemind implements the TreadMarks API.
This file contains the implementation of the Barrier and Lock managers ¶
Package hivemind implements the TreadMarks API.
This file contains the implementation of the PageArray and PageEntry objects ¶
Package hivemind implements the TreadMarks API.
This file contains the implementation of the processor array and processor entry objects
Package hivemind implements the TreadMarks API.
This file contains the implementation of the vector timestamp ¶
Package hivemind implements the TreadMarks API.
This file contains the implementation of the WriteNoticeRecord
Index ¶
- Constants
- Variables
- func ApplyDiff(page []byte, diff Diff)
- func BarrierCall(caller string)
- func DumpLog()
- func InitManager(initList []string, Tx chan ipc.IpcMessage)
- func VCToArray(vc *Vclock) []uint
- type BarrierRequest
- type BarrierResponse
- type Diff
- type DiffChar
- type DiffInfo
- type DiffRequest
- type DiffResponse
- type HM
- func (hm *HM) Barrier(b uint8)
- func (hm *HM) ConnectToPeers(ids []uint8, ips []string)
- func (hm *HM) CreateInterval()
- func (hm *HM) Exit()
- func (hm *HM) Free(addr int) error
- func (hm *HM) GetNProcs() uint8
- func (hm *HM) GetProcID() uint8
- func (hm *HM) IncorporateIntervals(intervals []IntervalRec)
- func (hm *HM) LockAcquire(lock uint8)
- func (hm *HM) LockRelease(lock uint8)
- func (hm *HM) Log(f string, a ...interface{})
- func (hm *HM) LogDebug(f string, a ...interface{})
- func (hm *HM) LogError(f string, a ...interface{})
- func (hm *HM) LogInfo(f string, a ...interface{})
- func (hm *HM) LogMsg(f string, a ...interface{})
- func (hm *HM) Malloc(size int) (int, error)
- func (hm *HM) Read(addr int) (val byte, err error)
- func (hm *HM) ReadFloat(addr int) (val float64, err error)
- func (hm *HM) ReadN(addr int, len int) (val []byte, err error)
- func (hm *HM) SetDebug(level int)
- func (hm *HM) Startup(gvec string)
- func (hm *HM) StartupTipc(port int, gvec string)
- func (hm *HM) Write(addr int, val byte) error
- func (hm *HM) WriteFloat(addr int, val float64) error
- func (hm *HM) WriteN(addr int, val []byte) error
- type HiveMind
- type IntervalRec
- type IntervalRecord
- type IntervalRecordIf
- type Lock
- type LockAcquireRequest
- type LockAcquireResponse
- type MD
- type ManaStruct
- type Manager
- type PageArray
- type PageEntry
- func (pe *PageEntry) AddCopySet(proc uint8)
- func (pe *PageEntry) AddWN(proc uint8, wn *WriteNotice)
- func (pe *PageEntry) DelTwin()
- func (pe *PageEntry) DumpWriteNotices() string
- func (pe *PageEntry) GetCopySet() []uint8
- func (pe *PageEntry) GetDiffRange(proc uint8) (start *Vclock, end *Vclock)
- func (pe *PageEntry) GetManager() uint8
- func (pe *PageEntry) GetPageID() int
- func (pe *PageEntry) GetPageStatus() shm.Prot
- func (pe *PageEntry) GetTwin() []byte
- func (pe *PageEntry) HasCopy() bool
- func (pe *PageEntry) SetHasCopy(h bool)
- func (pe *PageEntry) SetManager(m uint8)
- func (pe *PageEntry) SetPageStatus(prot shm.Prot)
- func (pe *PageEntry) SetTwin(twin []byte)
- type PageRequest
- type PageResponse
- type ProcArray
- func (pa *ProcArray) Dump() string
- func (pa *ProcArray) GetLastRecord(p uint8) *IntervalRecord
- func (pa *ProcArray) GetLatestLocalTimestamp(pid uint8) *Vclock
- func (pa *ProcArray) GetMissingIntervals(vc *Vclock) []IntervalRec
- func (pa *ProcArray) GetProcMissingIntervals(pid uint8, vc *Vclock) []IntervalRec
- func (pa *ProcArray) InsertInterval(pid uint8, interval *IntervalRecord)
- func (pa *ProcArray) InsertIntervalRec(hm *HM, interval IntervalRec) *IntervalRecord
- type Vclock
- func (vc *Vclock) Compare(vc2 *Vclock) []int
- func (vc *Vclock) Copy() *Vclock
- func (vc *Vclock) Covers(vc2 *Vclock) bool
- func (vc *Vclock) GetInterval(id uint8) (uint, error)
- func (vc *Vclock) Increment(id uint8) (uint, error)
- func (vc *Vclock) IsIdentical(vc2 *Vclock) bool
- func (vc *Vclock) Merge(vc2 *Vclock) *Vclock
- func (vc *Vclock) Min(vc2 *Vclock) *Vclock
- func (vc Vclock) String() string
- func (vc *Vclock) Update(id uint8, time uint)
- type WriteNotice
- type WriteNoticeIf
Constants ¶
const ( LOCKREQ = 10 /* Lock Acquirer -> Lock Holder */ LOCKRSP = 11 /* Lock Holder -> Lock Acquirer */ DIFFREQ = 20 /* PagefaultHandler -> Writers */ DIFFRSP = 21 /* Writers -> PageFaultHandler */ PAGEREQ = 30 /* PageFaultHandler -> Page Owner */ PAGERSP = 31 /* Page Owner -> PageFaultHandler */ BARRREQ = 40 /* Barrier Client -> Barrier Manager */ BARRRSP = 41 /* Barrier Manager -> Barrier Client */ )
List of Message IDs sent between the HiveMind drones (i.e. nodes)
Variables ¶
var LogChan chan string = make(chan string, 100)
Functions ¶
func BarrierCall ¶
func BarrierCall(caller string)
func InitManager ¶
func InitManager(initList []string, Tx chan ipc.IpcMessage)
Types ¶
type BarrierRequest ¶
type BarrierRequest struct { BarrierID uint8 Vc Vclock Intervals []IntervalRec }
type BarrierResponse ¶
type BarrierResponse struct { Intervals []IntervalRec Vc Vclock }
type Diff ¶
type Diff []DiffChar
Diff is the data structure that describes the diff between two pages
type DiffRequest ¶
type DiffResponse ¶
type DiffResponse struct { Page int16 WN []WriteNotice }
type HM ¶
type HM struct { VC Vclock // local vector clock // contains filtered or unexported fields }
HM encapsulates the entire HiveMind DSM data
func NewHiveMind ¶
NewHiveMind creates a new instance of the HM struct and initializes data structures
func (*HM) Barrier ¶
Barrier blocks the calling process until all other processes arrive at the barrier
func (*HM) ConnectToPeers ¶
ConnectToPeers is a test function to work with tipc for uniting testing hivemind. Will be replaced by ipc later
func (*HM) CreateInterval ¶
func (hm *HM) CreateInterval()
CreateInterval creates a new interval record for the current interval; and for all the pages modified during the interval it creates write notice records.
func (*HM) IncorporateIntervals ¶
func (hm *HM) IncorporateIntervals(intervals []IntervalRec)
IncorporateIntervals is called by the lock acquirer to incorporate the information received in the reply in its own data structures. Notice that the system creates a diff for writable pages for which a write notice was received. This is important to allow the system to distinguish the modifications made by concurrent writers to the page. The status of the pages for which write notices were received in the reply is set to no-access. When the acquirer tries to access one of the invalidated pages the system invokes the PageFaultHandler
func (*HM) LockAcquire ¶
LockAcquire blocks the calling process until it acquires the specified lock
func (*HM) LockRelease ¶
LockRelease releases the specified lock
func (*HM) Log ¶
Log is called by all of the log functions and formats the messages and puts on the global Log channel
func (*HM) SetDebug ¶
SetDebug sets the debug message level. Lower levels are included in higher levels 0 - disable all output 1 - Enable Error messages 2 - Enable Info messages 3 - Enables IPC message trace 4 - Enable Debug messages
func (*HM) StartupTipc ¶
StartupTipc starts hivemind with test ipc library for unit testing
func (*HM) WriteFloat ¶
WriteFloat writes a float at the specified address
type HiveMind ¶
type HiveMind interface { // Allocates a block of free memory and returns the start of that block // Can return the following errors: // - InsufficientMemory Malloc(size int) (int, error) // Frees a previously allocated block of memory. // Can return the following errors: // - InvalidAddress // - Free(addr int) error // Starts the HiveMind DSM on all processors. It should be the first call Startup() // Exit is called to shutdown the HiveMind DSM. Exit() // Barrier blocks the calling process until all other processes arrive at the barrier Barrier(b uint8) // LockAcquire blocks the calling process until it acquires the specified lock LockAcquire(lock uint8) // LockRelease releases the specified lock LockRelease(lock uint8) // GetNProcs gets the number of processors configured for this DSM GetNProcs() uint8 // GetProcID gets the processor ID of this process GetProcID() uint8 // Read a single byte at the specified address or Read array of bytes // Can return the following errors: // - Read(addr int) (byte, error) ReadN(addr int, len int) ([]byte, error) ReadFloat(addr int) (float64, error) // Write a byte at address or write an array of bytes starting at address // Can return the following errors: // - Write(addr int, val byte) error WriteN(addr int, data []byte) error WriteFloat(addr, val float64) error }
HiveMind interface describes the entire HiveMind DSM interface
type IntervalRec ¶
IntervalRec is a slightly different version of the IntervalRecord It is used for the messaging and does not contain list of WriteNotices. Instead it contains just the list of modified pages as described in Costa
type IntervalRecord ¶
type IntervalRecord struct { ProcID uint8 // id of process which created the interval Vc *Vclock // vector time of creator WriteNotices []*WriteNotice // list of write notice records for this interval. }
IntervalRecord describes the interval
func NewIntervalRecord ¶
func NewIntervalRecord(pid uint8, vc *Vclock) *IntervalRecord
NewIntervalRecord is constructor for an interval record
func (*IntervalRecord) AddWN ¶
func (i *IntervalRecord) AddWN(wn *WriteNotice)
AddWN adds the WriteNotice to the record
func (*IntervalRecord) DelWN ¶
func (i *IntervalRecord) DelWN(wn *WriteNotice)
DelWN deletes the WriteNotice from the record
func (*IntervalRecord) GetID ¶
func (i *IntervalRecord) GetID() uint8
GetID gets the procID of the record
func (*IntervalRecord) GetTS ¶
func (i *IntervalRecord) GetTS() *Vclock
GetTS gets the vector timestamp
func (*IntervalRecord) GetWN ¶
func (i *IntervalRecord) GetWN() []*WriteNotice
GetWN gets the list Write Notice pointers in the interval
func (IntervalRecord) String ¶
func (i IntervalRecord) String() string
type IntervalRecordIf ¶
type IntervalRecordIf interface { //GetID gets the procID of the record GetID() uint8 // GetTS gets the vector timestamp GetTS() Vclock //GetWN gets the list Write Notice pointers in the interval GetWN() []*WriteNotice //AddWN adds the WriteNotice to the record AddWN(wn *WriteNotice) //DelWN deletes the WriteNotice from the record DelWN(wn *WriteNotice) }
IntervalRecordIf defines the interface for InterfaceRecord types
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock holds the state of each lock in the system
type LockAcquireRequest ¶
type LockAcquireRequest struct { AcqID uint8 // ID of the Acquirer since this message is forwarded LockID uint8 Vc Vclock }
Define the list of structures used for Request/Response handlers
type LockAcquireResponse ¶
type LockAcquireResponse struct { LockID uint8 Vc Vclock Intervals []IntervalRec }
type ManaStruct ¶
type ManaStruct struct { Txchan chan ipc.IpcMessage // contains filtered or unexported fields }
when all of tracker = curPhase, we know all drones have reached barrier. then we simply flip curPhase
func (*ManaStruct) Init ¶
func (ms *ManaStruct) Init(keylist []string, himpt *HM)
func (*ManaStruct) SetBar ¶
func (ms *ManaStruct) SetBar(drone string, message BarrierRequest)
type Manager ¶
type Manager interface {
// contains filtered or unexported methods
}
Manager manages the DSM processes
type PageArray ¶
type PageArray struct {
// contains filtered or unexported fields
}
PageArray is an array of PageEntries -- one for each processor
func NewPageArray ¶
NewPageArray creates a new instance of the page array
func (*PageArray) GetPageAddress ¶
func (*PageArray) GetPageEntry ¶
func (*PageArray) GetPageSize ¶
type PageEntry ¶
type PageEntry struct {
// contains filtered or unexported fields
}
PageEntry maintains the stats of shared page in the DSM
func NewPageEntry ¶
Page Entry Methods
func (*PageEntry) AddCopySet ¶
func (*PageEntry) AddWN ¶
func (pe *PageEntry) AddWN(proc uint8, wn *WriteNotice)
func (*PageEntry) DumpWriteNotices ¶
func (*PageEntry) GetCopySet ¶
func (*PageEntry) GetDiffRange ¶
func (*PageEntry) GetManager ¶
func (*PageEntry) GetPageStatus ¶
func (*PageEntry) SetHasCopy ¶
func (*PageEntry) SetManager ¶
func (*PageEntry) SetPageStatus ¶
type PageRequest ¶
type PageRequest struct {
Page int16
}
type PageResponse ¶
type ProcArray ¶
type ProcArray struct {
// contains filtered or unexported fields
}
ProcArray maintains a list of interval records for each processor
func NewProcArray ¶
NewProcArray creates a new instance of the procArray
func (*ProcArray) GetLastRecord ¶
func (pa *ProcArray) GetLastRecord(p uint8) *IntervalRecord
GetLastRecord gets the latest interval record for a processor
func (*ProcArray) GetLatestLocalTimestamp ¶
GetLatestLocalTimestamp gets the latest local timestamp known for a specific processor
func (*ProcArray) GetMissingIntervals ¶
func (pa *ProcArray) GetMissingIntervals(vc *Vclock) []IntervalRec
GetMissingIntervals gets the intervals on all processors not covered by TS
func (*ProcArray) GetProcMissingIntervals ¶
func (pa *ProcArray) GetProcMissingIntervals(pid uint8, vc *Vclock) []IntervalRec
GetProcMissingIntervals gets the intervals on a processor that is not covered by TS
func (*ProcArray) InsertInterval ¶
func (pa *ProcArray) InsertInterval(pid uint8, interval *IntervalRecord)
InsertInterval inserts an interval to the end of the processor list
func (*ProcArray) InsertIntervalRec ¶
func (pa *ProcArray) InsertIntervalRec(hm *HM, interval IntervalRec) *IntervalRecord
InsertIntervalRec inserts an new IntervalRecord from a IntervalRec. It also creates new writes notices for each of the pages in the Interval pages. The WN are added to the new interval record and also added to the page array. The Interval Record is then appended to the procArray
type Vclock ¶
type Vclock struct {
ClockMap []uint
}
Vclock Struct which includes the map that keeps track of intervals
func NewVectorClock ¶
Get new vector clock that does not contain any values
func (*Vclock) Compare ¶
Compare Returns a slice of ids which have interval values less than the current vector clock or are not present in the vector clock being compared to but present in the current vector clock Implementation may change
func (*Vclock) Covers ¶
Covers checks the VC covers another VC according to the covered definition described in Keleher.
func (*Vclock) GetInterval ¶
GetInterval Gets the interval for the given id
func (*Vclock) IsIdentical ¶
IsIdentical Checks if two vector clocks are identical, i.e. they have the same value for all processes
type WriteNotice ¶
type WriteNotice struct { ProcID uint8 // Creator of this Write Notice Diff *Diff // pointer to diff Vc *Vclock // pointer to the vector time when created PageID int // number of this page }
WriteNotice describes modifications to a page. Instead of including a link to the interval record we just put the timestamp and procID. It simplifies the messaging since we can use this structure in the message requests/responses
func NewWriteNotice ¶
func NewWriteNotice(page int, interval *IntervalRecord) *WriteNotice
NewWriteNotice creates a new Write Notice record using the parameters from the interval. The write notice is added to Page Array and to the Interval
func (*WriteNotice) EmptyDiff ¶
func (wn *WriteNotice) EmptyDiff() bool
SetDiff sets the diff in this record
func (*WriteNotice) GetDiff ¶
func (wn *WriteNotice) GetDiff() *Diff
GetDiff gets the pointer to the run-length encode page diff
func (*WriteNotice) GetPageID ¶
func (wn *WriteNotice) GetPageID() int
GetPageID gets the pageID of the record
func (*WriteNotice) GetTS ¶
func (wn *WriteNotice) GetTS() *Vclock
GetInterval gets the interval record
func (*WriteNotice) SetDiff ¶
func (wn *WriteNotice) SetDiff(diff *Diff)
SetDiff sets the diff in this record
func (WriteNotice) String ¶
func (wn WriteNotice) String() string
type WriteNoticeIf ¶
type WriteNoticeIf interface { //GetInterval gets the interval record GetInterval() *IntervalRecord // GetDiff gets the pointer to the run-length encode page diff GetDiff() *Diff // SetDiff sets the diff in this record SetDiff(diff *Diff) // GetPageID gets the pageID of the record GetPageID() int }
WriteNoticeIf defines methods supported by write notice records