TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How the Windows Subsystem for Linux Redirects Syscalls

359 pointsby jackhammonsalmost 9 years ago

20 comments

ataylor284_almost 9 years ago
&gt; The real NtQueryDirectoryFile API takes 11 parameters<p>Curiosity got the best of me here: I had to look this up in the docs to see how a linux syscall that takes 3 parameters could possibly take 11 parameters. Spoiler alert: they are used for async callbacks, filtering by name, allowing only partial results, and the ability to progressively scan with repeated calls.
评论 #11865608 未加载
评论 #11865880 未加载
评论 #11865591 未加载
luchsalmost 9 years ago
&gt;As of this article, lxss.sys has ~235 of the Linux syscalls implemented with varying level of support.<p>Is there a list of these syscalls somewhere? It would be cool to check it against the recent Linux API compatibility paper [0, 1].<p>[0]: <a href="http:&#x2F;&#x2F;oscar.cs.stonybrook.edu&#x2F;api-compat-study&#x2F;" rel="nofollow">http:&#x2F;&#x2F;oscar.cs.stonybrook.edu&#x2F;api-compat-study&#x2F;</a> [1]: <a href="http:&#x2F;&#x2F;www.oscar.cs.stonybrook.edu&#x2F;papers&#x2F;files&#x2F;syspop16.pdf" rel="nofollow">http:&#x2F;&#x2F;www.oscar.cs.stonybrook.edu&#x2F;papers&#x2F;files&#x2F;syspop16.pdf</a>
评论 #11865896 未加载
评论 #11865506 未加载
Maarten88almost 9 years ago
I have installed the current fast ring build and have tried installing several packages on Windows. Some do install and work (compilers, build environment, node, redis server), but packages that use more advanced socket options (such as Ethereum) or that configure a deamon (most databases), still end with an error. Compatibility is improving with every new build, and you can ditch&#x2F;reset the whole Linux environment on Windows with a single command, which is nice for testing.
评论 #11865391 未加载
cafalmost 9 years ago
<i>Since NT syscalls follow the x64 calling convention, the kernel does not need to save off volatile registers since that was handled by the compiler emitting instructions before the syscall to save off any volatile registers that needed to be preserved.</i><p>Say what? The NT kernel doesn&#x27;t restore caller-saved registers at syscall exit? This seems extraordinary, because unless it either restores them or zaps them then it will be in danger of leaking internal kernel values to userspace - and if it zaps them then it might as well save and restore them, so userspace won&#x27;t need to.
评论 #11867126 未加载
emcrazyonealmost 9 years ago
I can&#x27;t think of much that would benefit from this except for, perhaps, headless command line type applications. The one that comes to mind is rsync. Being able to compile the latest version&#x2F;protocol of rsync on a Linux machine and then running the same binary on a Windows host would be nice but fun seems to end there plus with Cygwin, this is largely a no-brainer without M$ help.<p>What about applications that hook to X Windows or do things like opening the frame buffer device. I&#x27;ve got a messaging application that can be compiled for both Windows and Linux and depending on the OS, I compile a different transport layer. Under Linux heavy use of epoll is used which is very different than how NT handles Async I&#x2F;O - especially with sockets. So my application&#x27;s &quot;transport driver&quot; is either compiling an NT code base using WinSock &amp; OVERLAPPED IO or a Linux code base using EPOLL and pthreads.<p>Over all it seems like a nice to have but I&#x27;m struggling to extract any real benefit.<p>Can anyone offer up some real good use cases I may be overlooking?
评论 #11865911 未加载
coverbandalmost 9 years ago
With this feature, if you&#x27;re a Linux developer, you&#x27;re automatically a Windows developer as well. Almost like being able to run all Android or iOS apps on Windows phones.[1][2]<p>[1] <a href="http:&#x2F;&#x2F;www.pcworld.com&#x2F;article&#x2F;3038652&#x2F;windows&#x2F;microsoft-kills-project-astoria-the-tool-designed-to-port-android-apps-to-windows-10.html" rel="nofollow">http:&#x2F;&#x2F;www.pcworld.com&#x2F;article&#x2F;3038652&#x2F;windows&#x2F;microsoft-kil...</a> [2] <a href="https:&#x2F;&#x2F;developer.microsoft.com&#x2F;en-us&#x2F;windows&#x2F;bridges&#x2F;ios" rel="nofollow">https:&#x2F;&#x2F;developer.microsoft.com&#x2F;en-us&#x2F;windows&#x2F;bridges&#x2F;ios</a><p>Edit: Now I am puzzled as to why this got downvoted?
评论 #11865435 未加载
Animatsalmost 9 years ago
It&#x27;s too bad that x86 hardware doesn&#x27;t do virtualization as well as IBM hardware. You can&#x27;t stack VMs. That&#x27;s exactly what&#x27;s needed here - a non-kernel VM that runs above NT but below the application.
评论 #11864712 未加载
评论 #11865386 未加载
评论 #11864898 未加载
kevincoxalmost 9 years ago
&gt; the Linux fork syscall has no <i>documented</i> equivalent for Windows<p>Emphasis is mine. I wonder if this is something that cygwin could (ab)use. Also I wonder why they would need this undocumented call.
评论 #11865944 未加载
评论 #11867982 未加载
评论 #11865938 未加载
评论 #11866384 未加载
bla2almost 9 years ago
Does anybody know how fork() is implemented? This blog post kind of sounds like fork() would do the slow emulation of it through CreateProcess().
评论 #11865518 未加载
obnauticusalmost 9 years ago
Excellent post, Jack.
quuxalmost 9 years ago
Interesting, I wonder how much overhead is added to syscalls to look up the process type. Does NT still do this check when no WSL processes are running?
评论 #11868618 未加载
_RPMalmost 9 years ago
Does Microsoft document all system calls?
评论 #11865813 未加载
davidgerardalmost 9 years ago
Yes, yes, but can we run Wine on it?
negusalmost 9 years ago
wtf is &quot;pico process&quot; and &quot;pico driver&quot;?
评论 #11868249 未加载
prirunalmost 9 years ago
Step 1: embrace
smegelalmost 9 years ago
Funny they don&#x27;t mention ioctl.
vegabookalmost 9 years ago
Next step is Microsoft basically needs to turn Windows into a flavour of Linux. If they don&#x27;t, they&#x27;re under massive pincer threat from Android and Chrome, which are rapidly becoming the consumer endpoints of the future. Windows is about to &quot;do an IBM&quot; and throw away a market that it created. See PS&#x2F;2 and OS&#x2F;2.<p>They should probably just buy Canonical. That would put the shivers into Google, properly.
评论 #11867245 未加载
评论 #11865802 未加载
zxcvcxzalmost 9 years ago
I use to run Linux in a VM on windows and use Chocolatey for package management and cygwin and powershell etc, then I realized I was just trying to make Windows into Linux. Seems to be the way things are going and with the addition of the linux subsystem it kind of proves that Windows really isn&#x27;t a good OS on it&#x27;s own, especially not for developers.<p>I wish Windows&#x2F;MS would abandon NT and just create a Linux distro. I don&#x27;t know anyone who particularly likes NT and jamming multiple systems together seems like an awful idea.<p>Windows services and Linux services likely won&#x27;t play nice together (think long file paths created by Linux services and other incompatibilities), for them to be 100% backward compatible they need to not only make Windows compatible with the things Linux outputs, but Linux compatible with the things windows services output, and to keep the Linux people from figuring out how to use Windows on Linux systems they&#x27;d need to make a lot of what they do closed source.<p>So I don&#x27;t see a Linux+Windows setup being deployed for production. It&#x27;s cool for developers, but even then you can&#x27;t do much real world stuff that utilizes both windows and Linux. If you&#x27;re only taking advantage of one system then whats the point of having two?<p>I went ahead and made the switch to Linux since I was trying to make Windows behave just like Linux.
评论 #11865459 未加载
评论 #11865460 未加载
dragonbonheuralmost 9 years ago
.
评论 #11865400 未加载
评论 #11865178 未加载
评论 #11865256 未加载
评论 #11865162 未加载
评论 #11865524 未加载
评论 #11865152 未加载
l3m0ndr0palmost 9 years ago
Pretty neat stuff. I think that MS should just create their own Linux Distribution &amp; port all MS products. Get rid of the Windows NT Kernel. I believe it&#x27;s outdated &amp; doesn&#x27;t have the same update cycle that the Linux Kernel has.<p>Why run a Linux Application&#x2F;binary on a windows server OS? When you can just run it on Linux OS and get better performance &amp; stability.
评论 #11865308 未加载
评论 #11865043 未加载