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

Username:   Password: 
 RegisterRegister   
 Why You Should Avoid Processes
Index -> Programming, Turing -> Turing Tutorials
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TokenHerbz




PostPosted: Wed Oct 26, 2005 4:13 am   Post subject: (No subject)

O M F G ???

i use mass proc's?? is that bad?
Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Wed Oct 26, 2005 4:40 am   Post subject: (No subject)

Matters what you mean by proc.

In Turing procedure = proc, process = process.
beard0




PostPosted: Wed Oct 26, 2005 11:13 am   Post subject: (No subject)

Martin, I know I'm somewhat late, but a perfect example of a program that requires a process:

code:
var connected := false
var userString := ""
var ch : string (1)
var stream : int
var inAddr : string

process GetConnect
    stream := Net.WaitForConnection (3942, inAddr)
    connected := true
end GetConnect

fork GetConnect

loop
    if hasch then
        getch (ch)
        userString += ch
    end if
    exit when connected
end loop

if stream > 0 then
    if userString = "" then
        put : stream, "The user did not enter anything."
    else
        put : stream, userString
    end if
end if


Otherwise, I agree that processes should not be used - Net.WaitForConnection is the only legitimate use I see for them.
[Gandalf]




PostPosted: Wed Oct 26, 2005 11:30 am   Post subject: (No subject)

Or if you want to play Turing's music (ie. play()) in the background. If you are playing it from a file, anything like Music.PlayFileLoop() will work without a process.
beard0




PostPosted: Wed Oct 26, 2005 11:57 am   Post subject: (No subject)

For my high scool programming class we used the old DOS Turing. I wanted to have background music in my final project which meant, in the DOS version, using play("abcd") etc. The problem was that the play command returned as it began to play the last note only. Thankfully, we were graced with a function playdone, which allowed me to do this:

code:
var music : string := ">8gf+fe-4e8<g+a>4c8ac4d<"
var place := 1
proc background
    if playdone then
        play (music (place))
        place += 1
        if place > length (music) then
            place := 1
        end if
        background
    end if
end background


And then I placed a call to background all throughout my code. This way, I only ever played one note at a time, so the call returned instantly.

Note: this does not work under windows turing - it executes, yes, but doesn't sound right. Under the old DOS Turing though, it gave my program great background music.
[Gandalf]




PostPosted: Wed Oct 26, 2005 2:01 pm   Post subject: (No subject)

Interesting, good old DOS Turing Smile.

The reason why it doesn't sound correctly is because when OOT plays a sound, the last note is always cut off. Overall, Turing's music capabilities suck as much as or more than it does in all aspects Wink.
beard0




PostPosted: Wed Oct 26, 2005 2:50 pm   Post subject: (No subject)

Yeah, I know about the last note cut-off. It also cuts off the last note before a rest ("p"). In DOS it cuts off the last note played in the program. Such that somehow, only the final c of the second scale would be cut off in the program below. I have no idea how it managed to accomplish that. :shock:
code:
play("cdefg>abc<")
play("cdefg>abc<")
jrblast




PostPosted: Wed Jan 18, 2006 9:56 pm   Post subject: (No subject)

[Gandalf] wrote:
Personally, I have never had to use proccess' except for music - just stick to procedures.


Razz Same Very Happy...But till now i didnt really know there was a difference Embarassed I guess thats what happens when you rush through everything skipping the unnescessary basics...

Oh, and I used to think fork is supposed to do that o.O
Sponsor
Sponsor
Sponsor
sponsor
Guest




PostPosted: Tue May 30, 2006 9:14 pm   Post subject: (No subject)

Well one thing that helps a process is a delay. Look what this does compared to Cervantes program on the first page:

code:

process greetings (word : string)
    loop
        put word
        delay(1)
    end loop
end greetings

fork greetings ("Hi")
fork greetings ("Ho")
[/code]
Tony




PostPosted: Tue May 30, 2006 9:24 pm   Post subject: (No subject)

something a bit more interesting on processes
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Bored




PostPosted: Tue Jun 13, 2006 2:40 pm   Post subject: (No subject)

Well I just finished reading this argument and would like to offer to you a program I recently made that I actually felt justified in using a process (not the process DrawVariables, that was just lazyness and I'll be fixing that). Martin if you are still dead set againsts proceces I would like you to try and make this program without them yet allow for the capabilities that mine has, the ease of adding into another program, and the ability to run in parrallel with any runtime program without having to alter either program. although it is not yet finished I do beleive it is a great example of the correct use of processes.
isaiahk9




PostPosted: Thu May 01, 2008 6:29 pm   Post subject: Re: Why You Should Avoid Processes

Wait a minute! Processes being evil would explain why my main menu in my game is still malfunctioning. But I have 2 questions on how to avoid processes :
1. What if I need
a ) music playing
b ) a random integer is called (in an infinite loop) and according to the number between 1 and six, one of six animations will run. One animation has sound.
c ) an infinite loop asking the user to click whichever button he wants on the menu

2. And, a larger problem for my game, I need going :
a ) two processes things for people controlling their avatars
b ) gravity simultaneously going
c ) items to randomly appear from the sky
d ) music to play
e ) background to load over and over again (its animated)
Whoever has player Super Smash Brothers, or fighter games in general would get the picture.

If anybody could help me it would be much appreciated. If you do help me, your name will be listed in the credits and so will anyone you reference.
Thanx
r691175002




PostPosted: Thu May 01, 2008 6:47 pm   Post subject: Re: Why You Should Avoid Processes

I have yet to find a situation where a process is justified other than for blocking IO or if you need to take advantage of multiple cores (And that should only be done if you know what you are doing).
IMO It is a bad idea to start tossing threads at every problem if you don't even know what a mutex or race condition is, even if the language cleans up after you.
Vermette




PostPosted: Fri May 02, 2008 10:43 am   Post subject: RE:Why You Should Avoid Processes

Here's a good question to ask then:

Does Turing support a built in mutex facility? If no explicitly, then what operations (if any) are atomic to create a semaphore or some other kind of interprocess communication?
hahd




PostPosted: Fri Jan 28, 2011 5:24 pm   Post subject: RE:Why You Should Avoid Processes

um processes arent tht bad, they worked out fine on my christmas card but terminating a process at the right time might be a bit trick for that in turing you are welcome to use the return command which immediately exits a process. But View.Update.Area works like a charm as well. I used a combination of both in my christmas card however if i were redo i would do it without process.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 6 of 7  [ 99 Posts ]
Goto page Previous  1, 2, 3, 4, 5, 6, 7  Next
Jump to:   


Style:  
Search: