
-----------------------------------
mike200015
Sun Jan 30, 2005 2:52 pm

Process Vs. Procedure
-----------------------------------
Whats the difference between a process and a procedure? I know that to run things at the same time (fork) you need to use a process, but whats the difference between them?

-----------------------------------
Cervantes
Sun Jan 30, 2005 3:05 pm


-----------------------------------
Processes are evil.  Procedures are good (though functions are better).  
A process tries to do everything simotaneously, though it fails.  A procedure does not execute at the same time as any other code in your program.  If you call a procedure, the code in the procedure will execute; once that code is finished, the program will return to the main code.
If you haven't already, [url=http://www.compsci.ca/v2/viewtopic.php?t=407]read tony's process, procedure, and functions tutorial.
-Cervantes

-----------------------------------
zomg
Sun Jan 30, 2005 3:16 pm


-----------------------------------
Processes are evil.  Procedures are good (though functions are better).  
A process tries to do everything simotaneously, though it fails.  A procedure does not execute at the same time as any other code in your program.  If you call a procedure, the code in the procedure will execute; once that code is finished, the program will return to the main code.
If you haven't already, 

it can be good if u want to play music tho
but u have to fork it

-----------------------------------
mike200015
Sun Jan 30, 2005 3:21 pm


-----------------------------------
you can for music, so you can have for example 2 differenct songs playing at the same time?

-----------------------------------
md
Sun Jan 30, 2005 3:21 pm


-----------------------------------
A procedure is a peice of code that Is called and run by other parts of your program. A process (a turning process, not a general process) is what other programming languages refer to as a thread. Every program starts with one thread. This thread is what actually runs your code. You can create more threads (turing processes) to run parts of your code concurently to the other threads (well, they don't really run at the same time, but close enough).

Threads are used for a large number of things, such as windows message handling (not applicable to turing), and timers (maybe appicable), as well as a host of other functions.

-----------------------------------
mike200015
Sun Jan 30, 2005 3:32 pm


-----------------------------------
Does function do the same thing as procedure? And how come everyone likes functions better than procedures. Also what can be used instead of process to make 2 things run simultaneously?

-----------------------------------
Cervantes
Sun Jan 30, 2005 3:33 pm


-----------------------------------
you can for music, so you can have for example 2 differenct songs playing at the same time?
IIRC, yes, but they cannot be of the same extension.  That is, you can have a .mp3 playing in the background and have .wav playing a noise of a rocket firing, for example.  But you cannot have a .mp3 playing with another .mp3.  (The reason I used the example I did is because it's a better idea to use .mp3 for background music because mp3's are smaller that wavs.)


(well, they don't really run at the same time, but close enough). 

No!  Not close enough!  :lol:

-Cervantes

-----------------------------------
md
Sun Jan 30, 2005 3:45 pm


-----------------------------------
Does function do the same thing as procedure? And how come everyone likes functions better than procedures. Also what can be used instead of process to make 2 things run simultaneously?

A procedure is simple a function that returns nothing. When people say that functions are better they are implying that it is better to always return something (which is NOT true).

In turning the only way I know of running two things at the same time is by using (turning) processes. If you use other languages you can use threads (turing process equivalent) or, depending on the level of comunication needed you can fork off an entirely new (real) process.

In the real world a process is a running program. It consists of the program code, the memory the program is using, and any other resources it has control of. Within this process are threads which actually run the code. By "forking" a new process all you are really doing is copying the process data, and creating a new thread for the copy.



(well, they don't really run at the same time, but close enough).

No! Not close enough! Laughing

-Cervantes

Well, it actually depends on your hardware (on p4s with HT they can actually both run at the same time :P), and for most pruposes, yes, they actually DO run concurrently. Unless you have done some research into operating systems and schedualing I don't think you want to argue with me :P
