Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Process Vs. Procedure
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mike200015




PostPosted: Sun Jan 30, 2005 2:52 pm   Post subject: 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?
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sun Jan 30, 2005 3:05 pm   Post subject: (No subject)

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, read tony's process, procedure, and functions tutorial.
-Cervantes
zomg




PostPosted: Sun Jan 30, 2005 3:16 pm   Post subject: (No subject)

Cervantes wrote:
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, read tony's process, procedure, and functions tutorial.
-Cervantes


it can be good if u want to play music tho
but u have to fork it
mike200015




PostPosted: Sun Jan 30, 2005 3:21 pm   Post subject: (No subject)

you can for music, so you can have for example 2 differenct songs playing at the same time?
md




PostPosted: Sun Jan 30, 2005 3:21 pm   Post subject: (No subject)

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




PostPosted: Sun Jan 30, 2005 3:32 pm   Post subject: (No subject)

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




PostPosted: Sun Jan 30, 2005 3:33 pm   Post subject: (No subject)

mike200015 wrote:
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.)

Cornflake wrote:

(well, they don't really run at the same time, but close enough).

No! Not close enough! Laughing

-Cervantes
md




PostPosted: Sun Jan 30, 2005 3:45 pm   Post subject: (No subject)

mike200015 wrote:
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.

Cervantes wrote:

Cornflake wrote:

(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 Razz), 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 Razz
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 8 Posts ]
Jump to:   


Style:  
Search: