java - Trying to make a program that imitates a Process Table -



i trying create program process table.
i have implement class pcb (process control block) several fields such as:
process name (a string)
process priority (an integer)
register set values (an object of class register set containing following fields: xar, xdi, xdo, pc.


then program needs create process table data structure either array (max size 100 elements) or arraylist of type pcb, , initialize array data file "processes1.txt" process table arrraylist has print out contents each process.


so questions are:
1. how many programs/classes have write? 3. first program creates process table arraylist of pcb. 2nd class pcb class defines pcb fields.
2. how first program initialize arraylist data text file?
3. use arraylist of arraylist? , how that?

thank in advance.

  1. processtable, processcontrolblock, registerset sound starts.
  2. i'd create method in processtable called load(file file) uses file, , perhaps textreader read configuration. there many ways read text file. google on bufferedinputstream. examples abound.
  3. arraylists can hold objects, , arraylist indeed object, yes. use easy: somearraylist.add(someotherarraylist); though declaration little harder:
arraylist<arraylist<string>> = new arraylist<arraylist<string>>(); 

which says 'a arraylist containing other arraylists containing strings.` there other ways write declaration little more general, shows gist.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -