forked from nguyentong77/CSS430-FileSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b896411
commit 7b0bece
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* Joseph Schooley & Nguyen Tong, CSS 430, Professor Sung | ||
CSS430 Final Project - File System | ||
TCB Class | ||
*/ | ||
public class TCB { | ||
private Thread thread = null; | ||
private int tid = 0; | ||
private int pid = 0; | ||
private boolean terminated = false; | ||
private int sleepTime = 0; | ||
public FileTableEntry[] ftEnt = null; // added for the file system | ||
|
||
public TCB( Thread newThread, int myTid, int parentTid ) { | ||
thread = newThread; | ||
tid = myTid; | ||
pid = parentTid; | ||
terminated = false; | ||
|
||
ftEnt = new FileTableEntry[32]; // added for the file system | ||
|
||
System.err.println( "threadOS: a new thread (thread=" + thread + | ||
" tid=" + tid + | ||
" pid=" + pid + ")"); | ||
} | ||
|
||
public synchronized Thread getThread( ) { | ||
return thread; | ||
} | ||
|
||
public synchronized int getTid( ) { | ||
return tid; | ||
} | ||
|
||
public synchronized int getPid( ) { | ||
return pid; | ||
} | ||
|
||
public synchronized boolean setTerminated( ) { | ||
terminated = true; | ||
return terminated; | ||
} | ||
|
||
public synchronized boolean getTerminated( ) { | ||
return terminated; | ||
} | ||
|
||
// added for the file system | ||
public synchronized int getFd( FileTableEntry entry ) { | ||
if ( entry == null ) | ||
return -1; | ||
for ( int i = 3; i < 32; i++ ) { | ||
if ( ftEnt[i] == null ) { | ||
ftEnt[i] = entry; | ||
return i; | ||
} | ||
} | ||
return -1; | ||
} | ||
|
||
// added for the file system | ||
public synchronized FileTableEntry returnFd( int fd ) { | ||
if ( fd >= 3 && fd < 32 ) { | ||
FileTableEntry oldEnt = ftEnt[fd]; | ||
ftEnt[fd] = null; | ||
return oldEnt; | ||
} | ||
else | ||
return null; | ||
} | ||
|
||
// added for the file systme | ||
public synchronized FileTableEntry getFtEnt( int fd ) { | ||
if ( fd >= 3 && fd < 32 ) | ||
return ftEnt[fd]; | ||
else | ||
return null; | ||
} | ||
} | ||
|