Exemplo n.º 1
0
 public void PrepSubmitReadConcurrent()
 {
     _concurrentRing.TryAcquireSubmission(out var s);
     s.PrepareNop();
     _concurrentRing.Release(s);
     _concurrentRing.Submit(out _);
     _concurrentRing.TryRead(out _);
 }
Exemplo n.º 2
0
        public unsafe void SubmissionWithInvalidArgumentsDoesNotIncrementDropped()
        {
            var r = new ConcurrentRing(8);

            Assert.True(r.TryAcquireSubmission(out var submission));
            submission.PrepareNop(1u);
            r.Release(submission);

            Assert.True(r.TryAcquireSubmission(out submission));
            // prepare submission with invalid parameters
            submission.PrepareReadWrite(99, -1, (void *)IntPtr.Zero, -12, 0, 0, 2u, SubmissionOption.None);
            r.Release(submission);

            Assert.True(r.TryAcquireSubmission(out submission));
            submission.PrepareNop(3u);
            r.Release(submission);

            Assert.True(r.TryAcquireSubmission(out submission));
            submission.PrepareNop(4u);
            r.Release(submission);

            Assert.Equal(SubmitResult.SubmittedPartially, r.SubmitAndWait(3, out var submitted));
            Assert.Equal(2u, submitted);

            Assert.True(r.TryRead(out var c));
            Assert.Equal(1u, c.UserData);

            Assert.True(r.TryRead(out c));
            Assert.Equal(2u, c.UserData);
            Assert.Equal(EINVAL, -c.Result);

            // Submissions after invalid one are ignored by kernel without dropped being incremented
            Assert.False(r.TryRead(out _));

            // Our ring size is 8 with 2 SQE still unsubmitted... we should only be able to prepare 6 additional SQEs
            for (uint i = 0; i < 6; i++)
            {
                Assert.True(r.TryAcquireSubmission(out submission));
                submission.PrepareNop(5 + i);
                r.Release(submission);
            }
            Assert.False(r.TryAcquireSubmission(out submission)); // This would overwrite the previously unsubmitted SQE

            Assert.Equal(SubmitResult.SubmittedSuccessfully, r.Submit(out submitted));
            Assert.Equal(8u, submitted);

            for (uint i = 0; i < 8; i++)
            {
                Assert.True(r.TryRead(out c));
                Assert.Equal(3 + i, c.UserData);
            }
        }
Exemplo n.º 3
0
        public void SubmitIntermittedLinkedSubmissions()
        {
            var r = new ConcurrentRing(8);
            Span <Submission> submissions = stackalloc Submission[2];

            Assert.True(r.TryAcquireSubmissions(submissions));

            submissions[0].PrepareNop(options: SubmissionOption.Link);
            r.Release(submissions[0]);

            Assert.Equal(SubmitResult.SubmittedSuccessfully, r.Submit(out var submitted));
            Assert.Equal(1u, submitted);

            Assert.True(r.TryRead(out _));

            submissions[1].PrepareNop(options: SubmissionOption.Link);
            r.Release(submissions[1]);

            Assert.Equal(SubmitResult.SubmittedSuccessfully, r.Submit(out submitted));
            Assert.Equal(1u, submitted);

            Assert.True(r.TryRead(out _));
            Assert.False(r.TryRead(out _));
        }