Klife

From Shmuma

Jump to: navigation, search

Implementation of life game in linux kernel.

Links:

NB: Yes, I know about Multix's implementation, by my is better (NIH principle, hehe).

Contents

Project status

TODO:

  • Board resize
  • Timer interface
  • Life game rules

Done:

  • Board memory allocation
  • Calculation of board's size from memory allocated (integer square root using Newton's method)
  • /proc interface

User interface

We have a /proc interface which allows us:

  • create simulations,
  • run them in continous manner or step-by-step,
  • examine board state,
  • change board`s state.
  • destroy it.

/proc interface

Control interface lives in /proc/klife and has the following entries:

  • version — version of module
  • =status= -- information of currently active simulations and overral module status iinformation,
  • =boards/= -- directory with boards,
  • =boards/create= -- control file which allows to create boards,
  • =boards/destroy= -- control file which allows to destroy boards,

Every board identified by integer number assigned sequentially on board's creation. It's state and control interface represented in =/proc/klife/boards/ID/= directory, which has the following entries:

  • =field= -- ASCII representation of board`s field,
  • =mode= -- board's mode of simulation. It can be =step= for manual tracing or =run= for automatic simulation.
  • =delay= -- interval in microseconds between board's step in =run= mode,
  • =step= -- integer counter of board's generations passed,
  • =status= -- overral board's status information,
  • =enabled= -- 0 or 1.

Board defnition

To fill board with data, you can use =/proc/klife/boards/NN/board= file (where =NN= is the board's ID). It handles the following write requests in text form (one per line):

  • =set X Y= -- set cell (X,Y) flled,
  • =clear X Y= -- clear cell (X,Y),
  • =toggle X Y= -- invert cell (X,Y) state.

Board is resized automatically.

Board status

To obtain current state of board, just cat =/proc/klife/boards/NN/board=.

Personal tools