On 4/19/24 02:45, Gernot Heiser via Devel wrote:
> On 19 Apr 2024, at 14:00, Andrew Warkentin <andreww...@gmail.com> wrote:
>>
>> Somehow I said Send()/Recv()/Reply() when I meant Call()/Recv()/Send()
>> (MCS of course doesn't even have a distinct Reply() function).
> 
> the correct syscall to use is ReplyWait():
> 
> Recv(…);
> while (1) {
>       ReplyWait(…);
> }
> 
> Es per my blog: Send() and Recv() should only ever be used in initialisation 
> and exception handling.
> 
>> The QNX/Linux equivalent is:
>>
>> int main()
>> {
>>    char buf[100];
>>    int f = open("/dev/null", O_WRONLY);
>>    int i;
>>    for (i = 0; i < 10; i++) {
>>        uint64_t start = __rdtsc();
>>        uint64_t end;
>>        int j;
>>        for (j = 0; j < 10000; j++){
>>            if (write(f, buf, 100) != 100){
>>                printf("cannot write\n");
>>                exit(1);
>>            }
>>        }
>>        end = __rdtsc();
>>        printf("cycles: %u\n", end - start);
>>    }
>> }
> 
> so you’re using standard I/O to /dev/null
> 
> My Posix is a bit rusty, but this should be buffered in the library (i.e. 
> most calls will *not* result in a system call).

Not true on any *nix I am familiar with.  The buffered version is fwrite().
write() always results in a real system call.

That said, I know nothing about QNX other than it being based on a microkernel.
It might be that QNX _does_ implement userspace buffering for write() and avoid
the system call overhead in this benchmark.
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)

_______________________________________________
Devel mailing list -- devel@sel4.systems
To unsubscribe send an email to devel-leave@sel4.systems

Reply via email to