Home
Top.Mail.Ru Yandeks.Metrika
Forum: "WinAPI";
Current archive: 2004.12.12;
Download: [xml.tar.bz2];

Down

Fiber Find similar branches


Scorpion   (2004-10-30 15:56) [0]

The working principle of the CreateFiber, ConvertThreadToFiber functions is not clear.
When they are called for some reason, the pointer to the fiber remains equal to nill. Please, help.



MBo ©   (2004-10-30 16:15) [1]

You can read about it in Richter's book.

> Please help.
And you brought the code so that the conversation was not pointless?

By the way, for what reason did you need to use Fibers?



Scorpion   (2004-10-30 16:36) [2]

It is possible, but there are examples in C ++, and I know little about this language.
In theory, everything seems clear to me, but in practice, nothing works.

procedure f;
begin
Form1.Edit1.Text: = "???";
end;

procedure TForm1.Button2Click (Sender: TObject);
var p, p2: pointer;
begin
p: = nil;
p2: = nil;
ConvertThreadToFiber (p);
(CreateFiber (0, @ f, p2));
SwitchToFiber (p2);
end;

p, p2 remain nil; SwitchToFiber (p2) throws an error.



Scorpion   (2004-10-30 16:45) [3]

Out of curiosity. I want to understand what new opportunities open up when using them.



DiamondShark ©   (2004-10-30 17:02) [4]


> I want to understand what new opportunities open up when they are applied.

None.



MBo ©   (2004-10-30 17:11) [5]

in my inexperienced view, there is no benefit from their use. as Richter writes, they were introduced for the convenience of porting Unix developments, while there is no system support or execution planning like threads - all by hand.



Scorpion   (2004-10-30 17:13) [6]

Why then created them?



Scorpion   (2004-10-30 17:17) [7]

I know that. Nevertheless, if you can, please explain: why in my example nothing works?



Игорь Шевченко ©   (2004-10-30 17:22) [8]


> why does nothing work in my example?


And write down in steps what your example should do. You can for yourself, you can for the forum.



Scorpion   (2004-10-30 17:32) [9]

ConvertThreadToFiber (p); A stream is associated with a fiber
(CreateFiber (0, @ f, p2)); A fiber is created with the 1 mb stack and a pointer to the function f
SwitchToFiber (p2); Switching to the fiber at p2



Игорь Шевченко ©   (2004-10-30 18:24) [10]


> p, p2 remain nil


So you wrote at the very beginning that they are equal to nil - so they stayed.


> (CreateFiber (0, @ f, p2)); A fiber is created with the 1 mb stack.
> and a pointer to the function f


Read the description of the function, it has a return value. Which is usually passed to SwitchToFiber.



Scorpion   (2004-10-30 21:35) [11]

The function returns a longbool, although the description says otherwise. I assumed that the 3 parameter is variable (p2). So the problem is not solved: (((



Игорь Шевченко ©   (2004-10-30 22:26) [12]

Read the description of the CreateFiber function. Read Richter.



Scorpion   (2004-10-30 22:32) [13]

I read Richter and the description ... I read 3 day.
There are no answers to my questions there unfortunately: (((

The function (CreateFiber) returns a longbool, although the description says otherwise. I assumed that the 3 parameter is a variable (p2). So the problem is not solved: (((



Игорь Шевченко ©   (2004-10-30 22:51) [14]


> Function (CreateFiber) returns longbool


Alas, a glitch at Borland.

Her prototype was to be announced as
function CreateFiber (dwStackSize: DWORD; lpStartAddress: LPFIBER_START_ROUTINE; lpParameter: LPVOID): LPVOID; stdcall;



Scorpion   (2004-10-30 23:17) [15]

Slightly helped:

p: = nil;
p2: = nil;
p4: = GetFiberData;
p5: = GetFiberData;
p: = ConvertThreadToFiber (p4);
p2: = CreateFiber (0, @ f, p5);
SwitchToFiber (p2);

But SwitchToFiber (p2); does not switch to a function, but terminates the application.



Scorpion   (2004-10-30 23:28) [16]

EVERYTHING ... :))) It turned out. Thank you very much. :)))



Pages: 1 whole branch

Forum: "WinAPI";
Current archive: 2004.12.12;
Download: [xml.tar.bz2];

Top









Memory: 0.6 MB
Time: 0.063 c
8-1093890137
Pavel Landgraf
2004-08-30 22:22
2004.12.12
reading format RealAudio


6-1096646370
Quaker
2004-10-01 19:59
2004.12.12
POP3 Using


14-1101327397
Knight
2004-11-24 23:16
2004.12.12
10 bukazoidov on Megaphone-Moscow ...


1-1101417695
AP
2004-11-26 00:21
2004.12.12
DirectoryExists


3-1100598443
Explore
2004-11-16 12:47
2004.12.12
Work with reference books





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian Japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Español swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish