dining

package module
v0.0.0-...-6b2c873 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

dining implements the dining philosophers problem described in C A R Hoare's 1978 paper.

Index

Constants

View Source
const (
	Quit
)

Variables

This section is empty.

Functions

func Fork

func Fork(forkId uint8, reqs chan ForkReq)

The behaviour of a fork.

func Log

func Log(text string)

Pass log entries to the Logger via the channel.

func Logger

func Logger(log chan string, nolog bool)

Lgger creates the log file and writes the entries passed to via the channel.

func Philosopher

func Philosopher(philId uint8,
	room chan RoomReq,
	roomack chan any,
	fork1 chan ForkReq,
	fork2 chan ForkReq,
	forkack chan any,
	quitreq chan any)

Philosopher defines the life of a philosopher, enabled by communication with Forks and the Room.

func Room

func Room(reqs chan RoomReq, ack chan any)

Room regulates the attendance of the philosophers.

Types

type ForkReq

type ForkReq struct {
	Ack    chan any
	Action uint8
	// contains filtered or unexported fields
}

ForkReq describes a request from a philosopher to a fork.

type RoomReq

type RoomReq struct {
	Action uint8
	// contains filtered or unexported fields
}

RoomReq describes a request from a philosopher to the room.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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