예제 #1
0
        internal int ArchRead(Thread current, ref ExceptionRegisters regs, UserPtr userBuf, int len, uint pos, File file)
        {
            var buf = Globals.AllocateAlignedCompletionBuffer(len);

            if (!buf.isValid)
                return -ErrorCode.ENOMEM;

            var iocp = IOCompletion.CreateReadIOCP(current, userBuf, len, file, buf);

            var r = IPCStubs.ReadAsync(current.Parent.helperPid, current.impl._value.thread._value, new Pointer(buf.Location), fd, len, pos);

            if (r < 0)
            {
                iocp.Dispose();
                return r;
            }

            Globals.CompletionQueue.Enqueue(iocp);
            current.SaveState(ref regs);
            current.AsyncReturn = true;
            return 0;
        }
예제 #2
0
        internal int ArchWrite(Thread current, ref ExceptionRegisters regs, ref ByteBufferRef buf, int len, uint pos, File file)
        {
            if (!Globals.CompletionQueueAllocator.Contains(buf))
            {
                Arch.Console.WriteLine("inode-write: unimplemented");
                Arch.ArchDefinition.Panic();
            }

            var iocp = IOCompletion.CreateWriteIOCP(current, file, buf);
            var r = IPCStubs.WriteAsync(current.Parent.helperPid, current.impl._value.thread._value, new Pointer(buf.Location), fd, len, pos);

            if (r < 0)
            {
                iocp.Dispose();
                return r;
            }

            Globals.CompletionQueue.Enqueue(iocp);
            current.SaveState(ref regs);
            current.AsyncReturn = true;
            // Take the buffer
            buf = ByteBufferRef.Empty;
            return 0;
        }