banker.h

来自「eC++编译器源码」· C头文件 代码 · 共 28 行

H
28
字号
#pragma Banker
  typedef unsigned int Tag;
  typedef void *Manager;
  typedef void Guard(Manager m, Tag t, unsigned int r, boolean block);
      /* The guard is called by Block with TRUE to block a process and
         FALSE to unblock it.  Cancel must be used to withdraw a Block. */

  void Open(Manager &m, unsigned int Nprs, unsigned int Mres, unsigned int &resLimit[]);
  int Request(Manager m, Tag process, unsigned int resource, unsigned int amount);
    /* <0 request exceeds available by -value units
       0  request exceeds maximum claim
       1 unsafe state
       2 success
    */
  boolean Block(Manager m, Tag process, unsigned int resource, unsigned int amount, Guard p);
    /* blocks until request can be safely granted; returns TRUE if blocked */
    /* NOTE: block can be called multiple times for a "blocked" process. */
  void Cancel(Manager m, Tag process, unsigned int resource, unsigned int amount);
    /* used to cancel a currently blocked request; doesn't call the Guard */

  unsigned int Available(Manager m, unsigned int resource);

  void Release(Manager m, Tag process, unsigned int resource, unsigned int amount);
  void Close(Manager &m);

  Tag Process(Manager m, unsigned int &maxClaim[]);
  void Kill(Manager m, Tag &process);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?