TBone
December 7th, 2005, 14:42
This is sort of an odd-ball question, but have any of you ever encountered a commercial program (heck, *any* kind of program) that uses fibers? I.e. ConvertThreadToFiber, SwitchToFiber, etc.
I have no practical reason for asking this; it's just a passing curiosity. I was thumbing through Windows Internals and came across these critters in their introduction to processes and threads. I've never seen any program make use of any of those APIs. The more I thought about it, the weirder the entire concept seemed. About the only case I could make for doing your own user-mode threading would be if you were doing a ton of thread switching and didn't want to generate a ton of context switches for performance reasons. But then, why use the fiber APIs? I haven't traced through them to see where they lead, but I'd be surprised if they didn't wind up generating a context switch from user to kernel, and back again. That can't be any better than suspending one thread, popping to kernel mode, and resuming another.
Anyway, I haven't seen exactly what happens to the flow of execution when you switch to a different fiber, but it seems like there might be an opportunity here for a protection system. I guess I'll have to write a program sometime to play around with these, but it seems like you might be able to use these to help obfuscate and mangle your code's execution.
I have no practical reason for asking this; it's just a passing curiosity. I was thumbing through Windows Internals and came across these critters in their introduction to processes and threads. I've never seen any program make use of any of those APIs. The more I thought about it, the weirder the entire concept seemed. About the only case I could make for doing your own user-mode threading would be if you were doing a ton of thread switching and didn't want to generate a ton of context switches for performance reasons. But then, why use the fiber APIs? I haven't traced through them to see where they lead, but I'd be surprised if they didn't wind up generating a context switch from user to kernel, and back again. That can't be any better than suspending one thread, popping to kernel mode, and resuming another.
Anyway, I haven't seen exactly what happens to the flow of execution when you switch to a different fiber, but it seems like there might be an opportunity here for a protection system. I guess I'll have to write a program sometime to play around with these, but it seems like you might be able to use these to help obfuscate and mangle your code's execution.