dino

package
v0.0.0-...-98b984b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2015 License: GPL-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Process Types
	PT_INTERACTIVE    = ProcessType("Interactive")
	PT_NONINTERACTIVE = ProcessType("Noninteractive")

	// Burst Types
	BT_CPU = iota
	BT_IO
)
View Source
const FREE_BLOCK = string('▓')
View Source
const (
	MAX_INT = int(^uint(0) >> 1)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BurstType

type BurstType int

type Bursts

type Bursts []BurstType

type Dino

type Dino struct {
	Memory Memory
	// contains filtered or unexported fields
}

func New

func New(totalMemory int) *Dino

func (*Dino) CPU

func (d *Dino) CPU(p *Process)

func (*Dino) IO

func (d *Dino) IO(p *Process)

func (*Dino) MemorySize

func (d *Dino) MemorySize() int

func (*Dino) RandomProcess

func (d *Dino) RandomProcess() *Process

func (*Dino) Run

func (d *Dino) Run(max_epoch int)

Run a simulation of the Dino, during max_epoch iterations. If max_epoch <1, run indefinitely

func (*Dino) Step

func (d *Dino) Step() (state *DinoState, err error)

type DinoState

type DinoState struct {
	FreeMemory           int
	Memory               MemoryLayout
	MemoryArray          MemoryLayout
	NewQ                 []string
	InteractiveQ         []string
	ExtFragmentation     bool
	ExecutedByCPU        *Process
	ExecutedByIO         *Process
	FragmentationProcess *Process
	Message              string
}

func (*DinoState) String

func (ds *DinoState) String() string

type LongTimeSched

type LongTimeSched struct {
	PriorityQueue
	Scheduler

	sync.Mutex // adds Lock() & Unlock() methods for concurrency
	// contains filtered or unexported fields
}

Dispatcher: Se encarga de mover procesos de la cola de Ready hacia el CPU para su ejecución (realiza el cambio de contexto)

type Memory

type Memory []*Process

func (Memory) Allocate

func (m Memory) Allocate(p *Process, start int) (err error)

func (Memory) AllocateWorstFit

func (m Memory) AllocateWorstFit(p *Process) (err error)

func (Memory) HasSpace

func (m Memory) HasSpace(size int) bool

func (Memory) Layout

func (m Memory) Layout() MemoryLayout

func (Memory) ReleaseProcess

func (m Memory) ReleaseProcess(p *Process) (bool, error)

func (Memory) TotalFree

func (m Memory) TotalFree() int

func (Memory) WorstFit

func (m Memory) WorstFit(sizeToFit int) (start, offset int, err error)

type MemoryBlock

type MemoryBlock struct {
	Start int
	Size  int
	Name  string
}

type MemoryLayout

type MemoryLayout []*MemoryBlock

func (MemoryLayout) String

func (ml MemoryLayout) String() string

type MultilevelQueue

type MultilevelQueue struct {
	Scheduler
	// contains filtered or unexported fields
}

MultilevelQueue is a scheduler of schedulers

func (*MultilevelQueue) Add

func (m *MultilevelQueue) Add(p *Process) error

func (*MultilevelQueue) Get

func (m *MultilevelQueue) Get() (*Process, error)

func (*MultilevelQueue) Len

func (m *MultilevelQueue) Len() int

func (*MultilevelQueue) Name

func (m *MultilevelQueue) Name() string

func (*MultilevelQueue) New

func (m *MultilevelQueue) New(n string, q ...Scheduler)

func (*MultilevelQueue) Read

func (m *MultilevelQueue) Read() (*Process, error)

func (*MultilevelQueue) String

func (m *MultilevelQueue) String() []string

type PriorityQueue

type PriorityQueue []*Process

type Process

type Process struct {
	ID             string
	Name           string
	Type           ProcessType
	ProgramCounter int
	Bursts         Bursts
	IOBurst        time.Duration
	SizeInKB       int

	IsAllocated   bool
	MemoryAddress int
}

func (*Process) Lifespan

func (p *Process) Lifespan() int

type ProcessType

type ProcessType string

type Processes

type Processes []*Process

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func (*Queue) Add

func (q *Queue) Add(p *Process) error

func (*Queue) Get

func (q *Queue) Get() (*Process, error)

func (*Queue) Len

func (q *Queue) Len() int

func (*Queue) Name

func (q *Queue) Name() string

func (*Queue) Read

func (q *Queue) Read() (*Process, error)

func (*Queue) String

func (q *Queue) String() []string

type RoundRobin

type RoundRobin struct{}

type Scheduler

type Scheduler interface {
	Add(*Process) error
	Get() (*Process, error)
	Read() (*Process, error) // Read must return the same as get, without deletion
	Len() int
	Name() string
	String() []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL