For those who don't understand a lot about computers:
Which one is easier?
  • You have 100 hands trying to do something, with 3 blocks, and they all need to reach for a block.
  • You have 100 hands, with 100 blocks, and they all need to reach for a block.

For those who understand a lot about computers:
Which one is easier?
  • A computer has many registers(including things like stack pointers and processor pointers) and interrupts, and has 10 programs running. The computer is nice and has 3 copies of [stuff said above] and stores it in the CPU. The 10 programs can only use those 3 copies.
  • A computer has many registers(including things like stack pointers and processor pointers) and interrupts, and has 10 programs running. The computer has 3 main copies, as stated in the last option, stored in the processor. When a program is opened,(let's say the program is set up to do this) the CPU makes a copy and stores the copy(the copy is a set of registers, same amount as the CPU, and interrupts) in some type of Flash memory. The program accesses that copy as it's registers and interrupts sort of creating it's own mini CPU. However, the main CPU still processes all the instructions.


All numbers are able to be changed, and so are areas where I put things.
Which idea is better and why? If you have a better idea or a change to one of these, please explain.
My reason for this is to create this in Minecraft, and eventually create my own computer with this.
After some clarification on SAX, you've substantially invented threads.

Starting with a boring scalar CPU, you've got a set of registers that taken as a whole describe a program's state- including the program counter, stack pointer, etc. If you save a copy of these in memory somewhere, you can later reload them and restore the same program state (aside from the contents of memory, which may have changed). This is how operating systems do threading (with a little bit of support from the hardware)- usually an interrupt fires and the OS saves all the registers out to memory. It then selects a different thread, loads its saved registers and resumes execution of the other thread.

You now propose being able to create and execute arbitrary numbers of threads on a single CPU, somehow spawning additional resources for each thread. Certainly you can have more than one CPU (like in a a multicore system), but eventually you have more threads than CPUs and it's impossible to execute them all concurrently- you can't build an ALU (for example) out of software just by wishing for one, and physical resources will always be finite.

Some CPUs do simultaneous multithreading (SMT), which resembles your proposal in some ways. The CPU will keep multiple banks of registers, where each bank corresponds to a running thread. When a functional unit (say an ALU) is available and a running thread needs it, the corresponding register bank would get hooked up to that functional unit and the operation executed. This could be extended to store threads in main memory but would perform abysmally because main memory is extremely slow by the standards of most modern processors.

As practical examples, Intel's SMT implementation ("Hyperthreading") is only two threads per core, and in typical workloads will get around 30% more work done scheduling two threads on a single CPU than just one (though in some cases it's slower!). Other CPUs might go as high as 8 or 16 threads per CPU (some IBM POWER and Sparc machines), but I'm not sure what the performance is like. In general, SMT is useful for masking the costs of memory access but scheduling many threads on one CPU offers diminishing returns (but may be useful for providing more consistent if lower absolute per-thread performance).
That's the kind of answer I was looking for. Now, I'm learning assembly for the computer (as well as the TI-84+CE, but that's besides the point), from this, very slowly. Any recommendations on where I could learn computer systems/engineering? Other than the standard google search and school.
I've never found the actual processor manuals particularly opaque, and as the canonical documentation it's hard to beat the level of detail. I may be an outlier in ability to make sense of them, though.

I think AMD's manuals are a little easier to read, so have a look at the AMD64 Architecture Programmer’s Manual (start with volume 1 and refer to volume 3 as necessary, and use volume 2 for the kinds of things only an OS author needs to care about). Cross-reference with (or choose your favorite) the Intel 64 and IA-32 Architectures Software Developer Manuals (start with volume 1, refer to volume 2 and use 3 for OS stuff).
I'm not sure seanlego is ready to hit the ground running. Those manuals are extremely long, and they are intended for developing a kernel or BIOS (!!!) which get all the way down to the hardware level. It's almost amazing.
So I don't understand how to do signed and unsigned binary. Apparently, the MSB tells the sign, but what if you have an unsigned 8 bit number? How do you store that?
My thoughts go to just storing it in a bigger register. If this is the case, what do you do when you have an unsigned number big enough to fill the MSB in the biggest register?
seanlego23 wrote:
So I don't understand how to do signed and unsigned binary. Apparently, the MSB tells the sign, but what if you have an unsigned 8 bit number? How do you store that?
My thoughts go to just storing it in a bigger register. If this is the case, what do you do when you have an unsigned number big enough to fill the MSB in the biggest register?

For unsigned numbers, the MSB isn't important, so the value will occupy the entire 8 bits, giving you a range of values from 0 - 255. On the other hand, with signed numbers (in this case you most likely want 2's complement), the MSB is used as a sign flag. This means that you can store the values from -128 to + 127, since you only have 7 available bits.
MateoConLechuga wrote:
seanlego23 wrote:
So I don't understand how to do signed and unsigned binary. Apparently, the MSB tells the sign, but what if you have an unsigned 8 bit number? How do you store that?
My thoughts go to just storing it in a bigger register. If this is the case, what do you do when you have an unsigned number big enough to fill the MSB in the biggest register?

For unsigned numbers, the MSB isn't important, so the value will occupy the entire 8 bits, giving you a range of values from 0 - 255. On the other hand, with signed numbers (in this case you most likely want 2's complement), the MSB is used as a sign flag. This means that you can store the values from -128 to + 127, since you only have 7 available bits.

So how does a CPU know if the value is signed or unsigned?
seanlego23 wrote:
So how does a CPU know if the value is signed or unsigned?

All CPUs today (As far as I am aware) use the implementation of 2's complement which I mentioned above. This means that the CPU will preform the same type of operations regardless of the sign, but use the status flags so the programmer can know if there was a carry or a parity overflow in order to check for negativity. Basically, to a CPU, the value 4 (binary 00000100) and -4 (11111100) can be operated on exactly the same way. To learn more about 2's complement, check out this: http://www.tfinley.net/notes/cps104/twoscomp.html

Also keep in mind that it is not usually the CPU that performs the operations like this, but rather the Arithmetic Logic Unit (ALU).
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement