Dollars BBS | Technology

feed-icon

Main

News

Animation

Art

Comics

Films

Food

Games

Literature

Music

Personal

Sports

Technology

Random

Can a computer execute commands at the same time? (10)

1 Name: Noonimy : 2016-11-22 21:11 ID:oUrYW+UW [Del]

Hello everyone, this question have been given to use by our teacher in Computer Engineering and I'm quite not sure about what to answer to this question. I have known that a computer can multitask programs at the same time (i.e running multiple application in your desktop) but I'm not sure if this is "at exactly the same time" or it just seems like it is running at the same time... and also, I'm quite troubled at what my teacher means at commands, does he mean script commands or applications in the computer?

If you can please help out :)

2 Name: Sid : 2016-11-22 22:45 ID:EJP/4Yah [Del]

A computer can execute multiple things at the same time, if they use more than one transistor. But each transistor can only be a 0 OR 1, not both at the same time.

Usually a task is delegated to one CPU though. If you include code to use multiple cores then it can usually do more tasks at the same time. Yet most of the programming I have done only does it step by step, since I am only using 1 core. You can reference another program that another core does that can be combined.

Most programs are built around step by step, but one core can be doing something and another core can compile those things together. One major kind of processor designed around doing many tasks at once is a GPU. I think AMD tried reformatting how their GPU's multitasked through the code, while Nvidia tried focusing more on the hardware.

I would think that the GPU has many processes being compiled into one image, rather than only compile bits of the image in a sequential manner.

3 Name: Yuukio : 2016-11-23 06:45 ID:NUKOLFDJ [Del]

To answer your question, you need to know the difference between multiprogramming and multiprocessing which should be taught in Operating System Course.

From what I understand, multiprocessing can simultaneously process in different CPU cores.

Multiprogramming on another is when processes are constantly being scheduled and given some running duration (round robin scheduling). When you have multiple processes running, it seems to be running simultaneously but in fact it is just context switching from 1 process to another and back to the process.
Human can't differentiate the speed of processes being switch in and out, hence they look like they are running simultaneously.

You may wonder... how the processes keep track of intermediate results when all this switching here and there occurs.

It turns out that every time a process get switch out, they store those value in a data structure known as PCB and thus are able to continue what they were doing when the process get to run again.

4 Name: Yuukio : 2016-11-23 06:54 ID:NUKOLFDJ [Del]

if you are expecting answers regarding multi-threading when writing programs.

Yes, you can execute command at the same time ( multi-thread ).

From what I understand, multi-threading involves spawning of child processes from a parent process.

supposed I draw this diagram where x is the spawning point.
Beyond the spawning point, the child is executing at the same time as the parent in a different thread.

parent--------x -------------y----------->
..........child ----------> die

It is possible to be the commands to happen sequentially with the "wait" functions. The parent wait for child to complete before continuing.

parent--------x (....wait.....) -------------y----------->
............child ---------> die

I hope my answer helps your question.

5 Name: Noonimy : 2016-12-01 09:02 ID:O4Iw0MVA [Del]

I don't know if I can follow. So basically if you have more cores in your computer, you can run programs in each of these cores and you can run them simultaneously? Are you talking about "cores" of a CPU, like a dual core, quad core, or octa core? If you think about it that way then the maximum number of programs you can run in a computer is based on the cores it has, but it does not seem to be likely because a normal computer can have dozens of tabbed programs running. What "core" are you probably referring at?

6 Name: Valdr!ValdrPyl9. : 2016-12-03 03:38 ID:WL8Sk9ly [Del]

>>5 Yuukio gave a really fantastic answer that I believe went a little over your head. Yes, when Yuukio said cores, (s)he meant the cores of a CPU, as in a dual core processor, or quad core or what have you. But the amount of cores does NOT determine the max amount of programs you can have running. Even if you're running several programs at once, what your computer is really doing is splitting up the tasks or commands given to it by the programs being run and executing these commands one at a time. So if you're running multiple programs on a computer, the computer might be executive some commands from Program A, then executive some commands from Program B, then executing some commands from Program C, all while seemingly running these programs simultaneously. You can see this fall apart when one or more programs start to take up too many of the computer's resources and all the other functions begin to suffer because of it. This is basically what is happening when your computer freezes.

As for your teacher's question: you probably wanna look at Yuukio's response to answer that. I don't know what level class you're taking, so it's a bit harder for me to say. My suggestion is to study up on the materials provided to you and then go to Google for more answers.

7 Name: meowxiik : 2016-12-04 08:05 ID:6DU6EhNw [Del]

Simple explanation:
Computers can't *truthly* multitask. They can switch between tasks so quickly that you notice it, making the illusion of processing mutliple tasks at once.

P.S.: Not sure how it works with multi core CPUs. I *guess* they *can* truthly multitask, but I'm guessing here.

8 Name: Sid : 2016-12-06 00:47 ID:EJP/4Yah [Del]

^

9 Name: hiroki : 2016-12-24 03:49 ID:0D0uGnBo [Del]

>>7 yes, they can with multi core CPUs. Or several CPUs.

You can even run an os per core, even if that's not common.

10 Name: Foxtrot 4210 : 2016-12-31 23:33 ID:PkoSfAMT [Del]

I recommend an average android tablet