Closed mtfuller closed 8 years ago
The (very simple) Disk I created in my files to test my Loader is actually just a String. It's initialized as "", and the instruction lines are added to it: newDisk += line. Getting "job chunks" from this Disk is just a matter of grabbing substrings from the Disk, from certain beginning and ending characters (stored in the PCBs).
insert stupid question here When do we need a Word to represent a long number? Can you bring the instruction lines over to the CPU and do the conversions there?
Well, I think it all depends on how we approach storing the job instructions. Below are two main options that I can think of. I personally opt for option 1, since that would remove the Hexcode-to-Decimal conversion. I would love to hear everyone's thoughts, though.
All job/data hex strings are stored in the Disk as an array:
String disk[] = {"0x120A2B43", "0x100A2323", ...}
The Long Scheduler loads disk job/data hexcodes into RAM:
String ram[] = {"0x120A2B43", "0x100A2323", ...}
The CPU fetches a hexcode from RAM (ex. "0x120A2B43"
), and then converts it into a numerical value in order to be decoded and executed.
All job/data hex strings are converted to a numerical value and stored in the Disk as an array:
long disk[] = {1283982723, 2138482822, ...}
The Long Scheduler the numerical values into RAM:
long ram[] = {1283982723, 2138482822, ...}
The CPU fetches a numerical value from RAM (ex. 1283982723
), and then decodes and executes it immediately.
I think an integer may actually work. A long may not be necessary now that I have work on the CPU more.
I was working through the CPU last night, and I noticed that the
int
data type may not be sufficient.Since each instruction is 32-bits long (or a Word-long), a 32-bit number should be able to represent a number from 0 to 4.2 billion. However, the Java
int
type can only handle numbers from -2.1 billion to 2.1 billion. So, I think we need a way to represent an unsigned 32-bit-long number in Java.One solution to this is to use the
long
data type in Java, which spans from -9.2 x 10^18 to 9.2 x 10^18. I tried this out and it works, however, having the Disk store 2048long
data types will be much larger than that of an array full ofint
's.Would love to hear everybody else's thoughts.