boundedbuffer.h
来自「nachos test nachos 有关实验」· C头文件 代码 · 共 29 行
H
29 行
#include "synch-sleep.h"#include <malloc.h>class BoundedBuffer {
public:
// create a bounded buffer with a limit of 'maxsize' bytes
BoundedBuffer(int maxsize);
~BoundedBuffer();
// read 'size' bytes from the bounded buffer, storing into 'data'.
// ('size' may be greater than 'maxsize')
void Read(void *data, int size);
// write 'size' bytes from 'data' into the bounded buffer.
// ('size' may be greater than 'maxsize')
void Write(void *data, int size);
private:
int buffersize; int readyRead; int readyWrite; void *buffer; char *bufferend; char *nextin; char *nextout; Lock *lock; // enforce mutual exclusive access to the table Condition *notreadyRead; Condition *notreadyWrite;
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?