The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Danesh on March 11, 2005, 10:03:43 PM

Title: Using fibers...
Post by: Danesh on March 11, 2005, 10:03:43 PM
Hi all,

Here with MASM32 package, many good tutorials exist. For example about threads and processes and multitasking issues, here are some great examples (icztutes), but about working with Fibers such as creating fibers, managing fibers and... there is no example. Can anybody help to find samples or tutorials about fibers ?

Thanks,

Danesh



Title: Re: Using fibers...
Post by: James Ladd on March 11, 2005, 10:12:02 PM
Danesh,
Fibers (sometimes called green threads) are user managed and created threading. So you implement this yourself.
For example you would create a thread and have it slice its time between several tasks. Thus prividing flow
and processing within a thread. ie: If you split a cotton thread, you get fibers.
This has also been called "Cooperative threading" in the past.

Its not an API level thing supported by the Win32 platform.

There are a lot of good sources on the net about implementing threading and one of these should help you.

Why do you need to get to this level ?
Title: Re: Using fibers...
Post by: Danesh on March 12, 2005, 02:20:11 PM
Striker,

Thanks for information. As you know (you helped me in socket programming) I was working on a server program which had to create and manage threads. I was thinking about creating fiber in one thread instead of creating threads in threads. I think by creating fibers instead of threads overheads may decrease and the whole program would run in an more efficient way. Also, I think working with fibers is an API level supported thing because in API list there are some functions about working with fibers but maybe I am wrong. For example, here is CreateFiber API function's link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/createfiber.asp

Regards,

Danesh

Title: Re: Using fibers...
Post by: James Ladd on March 12, 2005, 09:52:10 PM
Danesh,
Ah, so there is an api for fibers. Kewl.
You will still have to work out a way to schedule them. ie: When to call switchTo.
This could be done with events on the IO completion of other things.
Personally I would wait for my framework to be finished as its not that far away ;)
If you want to continue with fibers then read about cooperative multitasking as
a way to schedule the fibers.
Rgs, striker
Title: Re: Using fibers...
Post by: Danesh on March 13, 2005, 11:11:24 AM
Striker,

Thanks. I will research more about multitasking and fibers. By the way, I believe that FastServer is GREAT and I REALLY LOVE IT. Of course I will use it. This server program is something else which will be substituted by FastServer.  :U


Title: Re: Using fibers...
Post by: James Ladd on March 13, 2005, 09:36:39 PM
Danesh,
Thanks. I will try and complete FAStServer as quick as I can so you can use it to its full potential.
Rgs, striker.