9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Steve Simon <steve@quintile.net>
To: 9front@9front.org
Subject: Re: [9front] etimer() assumes seconds together with APE
Date: Tue, 12 May 2020 16:34:57 +0100	[thread overview]
Message-ID: <DA119E30-9065-4F2D-96A3-269BB7EE5233@quintile.net> (raw)
In-Reply-To: <b0624a005092894a58ce617aec843bc1@oboj.net>

this brings back memories of the libplot on v7 unix, which had a close() entrypoint.

you had to link your app in two stages. the graphics stuff got bound to libplot with -r to keep the relocation data, then the result linked with the remainder of the app.

history just keeps repeating.

-Steve


> On 12 May 2020, at 5:10 pm, jamos@oboj.net wrote:
> 
> Dear list,
> 
> The function etimer(ulong key, int n) is used in libevent to get a timer event every 'n' milliseconds. However, if APE is used, etimer() delivers an event every 'n' second instead. The reason is that sleep() assumes seconds in APE and milliseconds in Plan 9.
> 
> I am aware that combining Plan 9 libraries with APE is a bit risky. When I earlier wanted to use etimer() in the netsurf framebuffer driver, I assumed it didn't work under APE, but I was not patient enough to wait 1000 seconds, when I thought it would fire after one second.
> 
> Would this be considered a bug? It would be more consistent if etimer() would take milliseconds as well under APE, and it would also be more handy if one would like to sleep less than a second. I tried to find APE programs that might depend on the current behaviour, but I don't think there are many.
> 
> The following test program prints a string every 10 seconds (in APE) and every 10ms (if it can manage) under native Plan9. Stop by killing the processes.
> 
> /* Compile under native plan9:
> *    8c ev.c; 8l -o native ev.8
> *
> * Compile under APE:
> *    pcc  -D_POSIX_SOURCE -D_PLAN9_SOURCE -o posix ev.c
> */
> 
> #include <u.h>
> #ifdef _POSIX_SOURCE
>    #include <stdlib.h>
> #else
>    #include <libc.h>
> #endif
> #include <draw.h>
> #include <event.h>
> 
> void
> eresized(int) {}
> 
> void
> main()
> {
>    int tim;    /* timer ticket */
>    int e;        /* type of event */
>    Event ev;    /* event struct */
> 
>    initdraw(0, 0, "timer test");
>    einit(Ekeyboard|Emouse);
>    tim = etimer(0, 10);    /* 10ms or 10s?*/
>    for(;;){
>        e = event(&ev);
>        if(e == tim)
>            print("Timer!\n");
> 
>    }
> }



  reply	other threads:[~2020-05-12 15:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-12 15:09 jamos
2020-05-12 15:34 ` Steve Simon [this message]
2020-05-12 15:39 ` [9front] " ori
2020-05-12 22:05   ` cinap_lenrek
2020-05-12 22:12     ` ori
2020-05-12 22:16 ` cinap_lenrek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DA119E30-9065-4F2D-96A3-269BB7EE5233@quintile.net \
    --to=steve@quintile.net \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).