Skip to content

Commit

Permalink
Fixed output formatting...correctly this time.
Browse files Browse the repository at this point in the history
  • Loading branch information
schooley committed Mar 14, 2014
1 parent 36c4333 commit 409b80b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/FileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public boolean format(int files) {
// file table contents must be closed
if (!filetable.fempty()) {
// TODO: omit or wait with while loop if this causes errors
SysLib.cerr("Cannot format superblock while file are in use.");
Kernel.report("Cannot format superblock while file are in use");
return false;
}
superblock.format(files);
Expand Down Expand Up @@ -82,7 +82,7 @@ public FileTableEntry open (String filename, String mode) {
!deallocateBlocks(fte)) {
// on failure, relieve entry from memory
filetable.ffree(fte);
SysLib.cerr("Could not deallocate all blocks.");
Kernel.report("Could not deallocate all blocks");
return null;
}
return fte;
Expand Down
16 changes: 9 additions & 7 deletions src/Kernel.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ public class Kernel {
// Error reporting
private final static String ERR_SR = "caused read errors";
private final static String ERR_SW = "cannot write to System.in";
private final static String ERR_DR = "Disk read failed!?";
private final static String ERR_DW = "Disk write failed!?";
private final static String ERR_DS = "Disk sync failed!?";
private final static String ERR_DR = "DISK read failed";
private final static String ERR_DW = "DISK write failed";
private final static String ERR_DS = "DISK sync failed";

// In case SysLib is modified / fails
private static void report(String err) {
System.out.println("ThreadOS: " + err);
// threadOS errors and status
public static void report(String msg) {
System.err.println("threadOS: " + msg);
}

// The heart of Kernel
Expand Down Expand Up @@ -186,8 +186,10 @@ public static int interrupt(int irq, int cmd, int param, Object args) {
report(ERR_SW);
return ERROR;
case STDOUT :
System.out.print(args);
return OK;
case STDERR :
report((String) args);
System.err.print(args);
return OK;
}
if ((myTcb = scheduler.getMyTcb()) == null)
Expand Down
4 changes: 3 additions & 1 deletion src/SuperBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public SuperBlock(int diskSize) {
of Inodes.
*/
public void format(int iNodes) {
Kernel.report((iNodes == defaultInodeBlocks ? "default " : "") + "format( " + iNodes + " )");

totalBlocks = Disk.blockSize;
totalInodes = iNodes;

Expand Down Expand Up @@ -84,7 +86,7 @@ public void sync() {
SysLib.int2bytes(totalInodes, block, 4);
SysLib.int2bytes(totalInodes, block, 8);
SysLib.rawwrite(0, block);
SysLib.cout("Superblock synchronized");
Kernel.report("Superblock synchronized");
}

/*getFreeBlock()
Expand Down
4 changes: 2 additions & 2 deletions src/TCB.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public TCB(Thread newThread, int myTid, int parentTid) {
ftEnt[i] = null;
// fd[0], [1], [2] are kept null for input, output, err

System.err.println("threadOS: a new thread (thread=" + thread + " tid="
+ tid + " pid=" + pid + ")");
Kernel.report("a new thread (thread=" + thread + " tid=" + tid + " pid="
+ pid + ")");
}

public synchronized Thread getThread() {
Expand Down

0 comments on commit 409b80b

Please sign in to comment.