Home | Networks | Community | Need Help? 

 
 Quick search

 
 
 RegisterRegister   Log inLog in 

Can it be done?
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    SearchIRC Forum Index -> Chat
Author Message
codemastr
Idler
Idler


Joined: 05 Feb 2004
Posts: 345

PostPosted: Jan 10, 2005 9:36pm    Post subject: Reply with quote

Quote:
What i meant to say was, threads are annoying. Yeah that's it.


They can be, but they don't have to be. In C they are difficult because C makes you do everything. In other languages, this is not the case. For example, in C, to "protect" a variable, you must create a mutex (lets assume Pthreads). So you create your mutex_t. Before you access theVar you request the mutex, then when you are done accessing it, you release it. If you forget to request and/or release it, you have a race condition (not good). The old example of this is that a guy has $50 in his bank account, he withdraws $50 from two ATMs at the same time, and the bank erroneously gives him $100, rather than informing him that the account is empty since both threads saw currentBalance == 50.00 and said "there are sufficient funds." Java, on the other hand, does this for you. In Java, I just add the keyword "synchronized" to the member I want to be protected, and Java handles all the mutex stuff for me. Java allows you to use synchronized more broadly to create virtually any critical section you need. Other languages go even further providing tools such as monitors. Threads are only complex in C because C is designed to be as efficient as possible. All these "extras" may make things safer and easier, but they also make things slower. C was designed for speed, not for safety.
Back to top
aquanight
Lurker
Lurker


Joined: 14 Jun 2004
Posts: 116
Location: Boise, ID

PostPosted: Jan 11, 2005 12:27am    Post subject: Reply with quote

My operating systems teacher gave us another example of that: where you have $50 in a bank, and you have a $25 paycheck being deposited or a $30 college bill ( Razz ) withdrawn at the same time, and either way you end up with the wrong amount of cash Razz . But yeah, another thing about threads are those nice things called deadlocks which are REALLY fun :/ . Unfortunaly I don't know of any languages that can help you bail out, but if you're watchful of how you manage your locks, you can easily avoid setting yourself up for those.
Back to top
w00t
Eleet
Eleet


Joined: 09 Jun 2004
Posts: 698
Location: Nowra, Australia

PostPosted: Jan 11, 2005 6:20pm    Post subject: Reply with quote

To clarify something: What I meant was, you can't read async without threading or some other method that code outlined (he'd know, having gone to university or whatever). Without some method to execute OUTSIDE the current scope, it'd be synchronous and would go back to the whole recipe idea

ie:
do_1();
do_2();
do_3();

would get executed in order, unless one of them was async, in which case, it finishes when it finishes.

Am I getting anywhere yet? Razz
Back to top
EqualSlashed_Brian
Lurker
Lurker


Joined: 29 Aug 2004
Posts: 221
Location: IRC

PostPosted: Jan 11, 2005 6:51pm    Post subject: Reply with quote

Asynchronous programs do not use threads. Period.
Back to top
braindigitalis
Idler
Idler


Joined: 22 Sep 2003
Posts: 443
Location: IRC

PostPosted: Jan 12, 2005 6:29pm    Post subject: Reply with quote

EqualSlashed_Brian wrote:
Asynchronous programs do not use threads. Period.


What you really mean is:

"Asynchronous programs do not explicitly use threads, although black-boxed system calls that they trigger may indeed spawn threads implicitly, that the developer of the program really doesnt need to know about or care about, so long as it works" Smile
Back to top
Cobi
Lurker
Lurker


Joined: 30 Dec 2003
Posts: 120
Location: IRC

PostPosted: Jan 15, 2005 12:01am    Post subject: Reply with quote

squirrel wrote:
geez, i wrote a 12,000 line PHP bot that runs on the server along side the ircd, just does goofy stuff really.

would you mind sending me the source? cobi@winbots.org
Back to top
codemastr
Idler
Idler


Joined: 05 Feb 2004
Posts: 345

PostPosted: Jan 15, 2005 11:08am    Post subject: Reply with quote

EqualSlashed_Brian wrote:
Asynchronous programs do not use threads. Period.


On this forum, it says your rank is "newbie." I guess this applies to your rank as a programmer as well, because you are dead wrong.
Back to top
Robert-E-Lee
Idler
Idler


Joined: 22 Nov 2004
Posts: 314
Location: IRC

PostPosted: Jan 15, 2005 12:00pm    Post subject: Reply with quote

Moderator's Note: Off-Topic.
Back to top
aquanight
Lurker
Lurker


Joined: 14 Jun 2004
Posts: 116
Location: Boise, ID

PostPosted: Jan 20, 2005 12:02am    Post subject: Reply with quote

You already established that unreal does not use threads. Ok fine. But Unreal DOES use asynchronous DNS resolution (duh). So if aysnchronous does not mean threads, then tell me why Task Manager tells me wircd.exe has 2 threads.
Back to top
EqualSlashed_Brian
Lurker
Lurker


Joined: 29 Aug 2004
Posts: 221
Location: IRC

PostPosted: Jan 20, 2005 9:11am    Post subject: Reply with quote

Leave me alone I only code in Python and not well! I just want to fit in. *cries* Sad
Back to top
zeke
Idler
Idler


Joined: 04 Oct 2003
Posts: 334

PostPosted: Jan 20, 2005 2:17pm    Post subject: Reply with quote

lol EqualSlashed_Brian
I'm a PHPer...and I'm n00b PHPer at that....I'm just as lost as the next guy...
Back to top
[DiMENSiON]
Eleet
Eleet


Joined: 06 Sep 2003
Posts: 670

PostPosted: Jan 20, 2005 2:39pm    Post subject: Reply with quote

I don't code.. 'cos i suck :P .. yeh so sue me..
Back to top
codemastr
Idler
Idler


Joined: 05 Feb 2004
Posts: 345

PostPosted: Jan 22, 2005 7:34pm    Post subject: Reply with quote

aquanight wrote:
You already established that unreal does not use threads. Ok fine. But Unreal DOES use asynchronous DNS resolution (duh). So if aysnchronous does not mean threads, then tell me why Task Manager tells me wircd.exe has 2 threads.

That has absolutely nothing to do with DNS at all. Unreal for Windows has 1 thread for the GUI, and 1 thread for the rest of the IRCd. Unreal does not create threads for asynchronous DNS. All of that is handled internally by the winsock library.
Back to top
aquanight
Lurker
Lurker


Joined: 14 Jun 2004
Posts: 116
Location: Boise, ID

PostPosted: Jan 26, 2005 11:00am    Post subject: Reply with quote

Erm, why would it have a GUI thread if I'm running it as an NT Service?
Back to top
Digital_Assassin
none
none


Joined: 20 Mar 2005
Posts: 4

PostPosted: Mar 20, 2005 12:31am    Post subject: Reply with quote

Ive been working on writing a C# ircd for about a yr. now, i just did a restart on a lot of the project because ive learned better ways of doin things too get the ircd too run the way i want, basically it runs like this ...

Theres 1 main server loop, and everything is basically asyncronous. The server loops through all clients/servers, and calls poll with a 0 timeout. If poll returns read ready, then it goes into an async read method, and reads all data from the client, the loop also checks bans, checks for ping timeouts ... I was gonna make it async read all together, but then id have too make a seperate timer for ping reply's, and checking the ban's ... Right now the ircd doesnt run ive been fixing up a lot of the code, but when i did have it running a while back it ran pretty stable. If anyone would like too help out with the project a bit, feel free too email bmyatt99@msn.com, or send me a msn msg!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    SearchIRC Forum Index -> Chat All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
 
Forum powered by phpBB
 
 © 2000 - 2008 EverythingIRC, Inc. All rights reserved. Please read our disclaimer