|
Last change
on this file since 1014 was 843, checked in by devigne, 12 years ago |
|
RWT Commit : Add soft directory.
Soft directory contains scripts used to validate the RWT protocol
|
|
File size:
1.6 KB
|
| Line | |
|---|
| 1 |
|
|---|
| 2 | #ifndef _variable_hpp_
|
|---|
| 3 | #define _variable_hpp_
|
|---|
| 4 |
|
|---|
| 5 | #include "assert.h"
|
|---|
| 6 |
|
|---|
| 7 | class Variable {
|
|---|
| 8 |
|
|---|
| 9 | int proc; // processor to which the variable belongs, -1 if public (most common case)
|
|---|
| 10 | int operation; // 0 : RW ; 1 : RO ; 2 : WO
|
|---|
| 11 | bool uncached; // Requests on this variable are done uncached
|
|---|
| 12 | bool in_trans_line; // if private variable, specifies whether the variable is located in a line containing transactional variables
|
|---|
| 13 |
|
|---|
| 14 | public:
|
|---|
| 15 |
|
|---|
| 16 | Variable(int proc, int operation, bool uncached, bool in_trans_line = true){
|
|---|
| 17 | assert(proc >= -1);
|
|---|
| 18 | assert(operation == 0 || operation == 1 || operation == 2);
|
|---|
| 19 | assert(in_trans_line || proc != -1);
|
|---|
| 20 | this->proc = proc;
|
|---|
| 21 | this->operation = operation;
|
|---|
| 22 | this->uncached = uncached;
|
|---|
| 23 | this-> in_trans_line = in_trans_line;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | Variable(){
|
|---|
| 27 | this->proc = -1;
|
|---|
| 28 | this->operation = 0;
|
|---|
| 29 | this->uncached = false;
|
|---|
| 30 | this->in_trans_line = true;
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | int getProc(){
|
|---|
| 34 | return proc;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | bool isRW(){
|
|---|
| 38 | return (operation == 0);
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | bool isRO(){
|
|---|
| 42 | return (operation == 1);
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | bool isWO(){
|
|---|
| 46 | return (operation == 2);
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | bool isUnc(){
|
|---|
| 50 | return uncached;
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | void setRO(){
|
|---|
| 54 | operation = 1;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | void setWO(){
|
|---|
| 58 | operation = 2;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | void setROorWO(){
|
|---|
| 62 | int n = randint(1,2);
|
|---|
| 63 | if (n == 1){
|
|---|
| 64 | operation = 1;
|
|---|
| 65 | }
|
|---|
| 66 | else {
|
|---|
| 67 | operation = 2;
|
|---|
| 68 | }
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | void setPrivate(int proc_id){
|
|---|
| 72 | proc = proc_id;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | void setUncached(){
|
|---|
| 76 | uncached = true;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | bool isPublic(){
|
|---|
| 80 | return (proc == -1);
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | bool isPrivate(int proc_id){
|
|---|
| 84 | return (proc == proc_id);
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | };
|
|---|
| 88 |
|
|---|
| 89 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.