From mboxrd@z Thu Jan 1 00:00:00 1970 From: yoann padioleau Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-Id: <4A54E518-87FB-4F82-84AA-BDCBD4DB0956@gmail.com> Date: Tue, 28 Apr 2015 21:28:44 -0700 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) Subject: [9fans] setitimer equivalent Topicbox-Message-UUID: 4e7ee23c-ead9-11e9-9d60-3106f5b1d025 Hi, I=E2=80=99m trying to port some code to plan9 using APE but I can=E2=80=99t find the setitimer function in any include/ape/ = files. What is the equivalent to setitimer under plan9? From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 References: <4A54E518-87FB-4F82-84AA-BDCBD4DB0956@gmail.com> In-Reply-To: <4A54E518-87FB-4F82-84AA-BDCBD4DB0956@gmail.com> From: "James A. Robinson" Date: Wed, 29 Apr 2015 04:38:03 +0000 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a11367b1477e7b50514d58bbb Subject: Re: [9fans] setitimer equivalent Topicbox-Message-UUID: 4e8372ac-ead9-11e9-9d60-3106f5b1d025 --001a11367b1477e7b50514d58bbb Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I'm not familiar with a function named settimer, is that from Windows? Given the name, would sleep/alarm fit your requirements? http://plan9.bell-labs.com/magic/man2html/2/sleep On Tue, Apr 28, 2015 at 9:31 PM yoann padioleau wrote: > Hi, > > I=E2=80=99m trying to port some code to plan9 using APE > but I can=E2=80=99t find the setitimer function in any include/ape/ files= . > What is the equivalent to setitimer under plan9? > > > --001a11367b1477e7b50514d58bbb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I'm not familiar with a function named settimer, = is that from Windows?=C2=A0 Given the name, would sleep/alarm fit your requ= irements?

http://plan9.bell-labs.com/magic/man2html/2/sleep
<= /div>
On Tue, Apr 28, 2015 at 9:31 PM yoann p= adioleau <aryx.padator@gmail.c= om> wrote:
Hi,

I=E2=80=99m trying to port some code to plan9 using APE
but I can=E2=80=99t find the setitimer function in any include/ape/ files.<= br> What is the equivalent to setitimer under plan9?


--001a11367b1477e7b50514d58bbb-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <31b636f9de93f12f6ecfc0b369f33515@proxima.alt.za> To: 9fans@9fans.net Date: Wed, 29 Apr 2015 06:55:27 +0200 From: lucio@proxima.alt.za In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] setitimer equivalent Topicbox-Message-UUID: 4e879116-ead9-11e9-9d60-3106f5b1d025 > I'm not familiar with a function named settimer, is that from Windows? > Given the name, would sleep/alarm fit your requirements? According to the Ubuntu man pages, setitimer(2) operates on one of three interval timers: ral, virtual and profile. It could take quite a bit of effort to port this to APE. I see that NetBSD echoes the Linux documentation. Lucio. From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 References: <31b636f9de93f12f6ecfc0b369f33515@proxima.alt.za> In-Reply-To: <31b636f9de93f12f6ecfc0b369f33515@proxima.alt.za> From: "James A. Robinson" Date: Wed, 29 Apr 2015 05:19:44 +0000 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a1139354a8f12910514d6201a Subject: Re: [9fans] setitimer equivalent Topicbox-Message-UUID: 4e96f6ce-ead9-11e9-9d60-3106f5b1d025 --001a1139354a8f12910514d6201a Content-Type: text/plain; charset=UTF-8 Sorry, I missed the extra 'i' in there. So is the requirement to get all three of those time domains supported? Supporting all three looks to me like something one would need for building real time systems or a profiling tool? On Tue, Apr 28, 2015 at 9:57 PM wrote: > > I'm not familiar with a function named settimer, is that from Windows? > > Given the name, would sleep/alarm fit your requirements? > > According to the Ubuntu man pages, setitimer(2) operates on one of > three interval timers: ral, virtual and profile. It could take quite > a bit of effort to port this to APE. I see that NetBSD echoes the > Linux documentation. > > Lucio. > > > --001a1139354a8f12910514d6201a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Sorry, I missed the extra 'i' in there.=C2=A0 So i= s the requirement to get all three of those time domains supported?=C2=A0 S= upporting all three looks to me like something one would need for building = real time systems or a profiling tool?

On Tue, Apr 28, 2015 at 9:57 PM <lucio@proxima.alt.za> wrote:
= > I'm not familiar with a function named settimer, is that from Wind= ows?
> Given the name, would sleep/alarm fit your requirements?

According to the Ubuntu man pages, setitimer(2) operates on one of
three interval timers: ral, virtual and profile.=C2=A0 It could take quite<= br> a bit of effort to port this to APE.=C2=A0 I see that NetBSD echoes the
Linux documentation.

Lucio.


--001a1139354a8f12910514d6201a-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <9c2e1610283e145f8f114f36bc830850@proxima.alt.za> To: 9fans@9fans.net Date: Wed, 29 Apr 2015 08:38:24 +0200 From: lucio@proxima.alt.za In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] setitimer equivalent Topicbox-Message-UUID: 4ea1ed5e-ead9-11e9-9d60-3106f5b1d025 > Sorry, I missed the extra 'i' in there. So is the requirement to get all > three of those time domains supported? Supporting all three looks to me > like something one would need for building real time systems or a profiling > tool? For the record, the NetBSD man pages suggest that Posix has declared setitimer and getitimer deprecated. Lucio. From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Wed, 29 Apr 2015 09:47:47 -0700 To: 9fans@9fans.net Message-ID: In-Reply-To: <4A54E518-87FB-4F82-84AA-BDCBD4DB0956@gmail.com> References: <4A54E518-87FB-4F82-84AA-BDCBD4DB0956@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] setitimer equivalent Topicbox-Message-UUID: 4eab7be4-ead9-11e9-9d60-3106f5b1d025 On Tue Apr 28 21:30:24 PDT 2015, aryx.padator@gmail.com wrote: > Hi, >=20 > I=E2=80=99m trying to port some code to plan9 using APE > but I can=E2=80=99t find the setitimer function in any include/ape/ fil= es. > What is the equivalent to setitimer under plan9? if you're ok on using nsec() as your time source, select(3) as posix woul= d have it, will do. - erik From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) From: yoann padioleau In-Reply-To: Date: Thu, 30 Apr 2015 20:21:05 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <32E4BD35-FCDC-4859-9034-82747001C411@gmail.com> References: <4A54E518-87FB-4F82-84AA-BDCBD4DB0956@gmail.com> To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Subject: Re: [9fans] setitimer equivalent, and sigvtalarm equivalent Topicbox-Message-UUID: 4eb01852-ead9-11e9-9d60-3106f5b1d025 Hi, I=E2=80=99m not sure I understand your proposal. But looking more at the code I need to port, an interpreter, I think the main issue is that the interpreter relies on sigvtalarm as a way to preempt the interpreted program while allowing the user program to use only sigalarm. So more generally the problem is how can I have two alarms in plan9? I see only one alarm signal in ape, SIGALRM. There is no SIGVTALRM. > On Apr 29, 2015, at 9:47 AM, erik quanstrom = wrote: >=20 > On Tue Apr 28 21:30:24 PDT 2015, aryx.padator@gmail.com wrote: >> Hi, >>=20 >> I=E2=80=99m trying to port some code to plan9 using APE >> but I can=E2=80=99t find the setitimer function in any include/ape/ = files. >> What is the equivalent to setitimer under plan9? >=20 > if you're ok on using nsec() as your time source, select(3) as posix = would > have it, will do. >=20 > - erik >=20 From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <14d0839475c3628914a71315dc2e21e5@9netics.com> To: 9fans@9fans.net Date: Fri, 1 May 2015 00:17:30 -0700 From: Skip Tavakkolian <9nut@9netics.com> In-Reply-To: <32E4BD35-FCDC-4859-9034-82747001C411@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-gkqpzlzlijdbvddidutdicsgmw" Subject: Re: [9fans] setitimer equivalent, and sigvtalarm equivalent Topicbox-Message-UUID: 4eb726e2-ead9-11e9-9d60-3106f5b1d025 This is a multi-part message in MIME format. --upas-gkqpzlzlijdbvddidutdicsgmw Content-Disposition: inline Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable one way to solve this would be to fork as many procs as there are timers; each would sleep the length of its timer value and then postnote an identifying artificial note (vtalarm, fooalarm, etc.) to the parent process. the parent process then interprets the artificial note as a particular type of alarm. -Skip > Hi, >=20 > I=E2=80=99m not sure I understand your proposal. >=20 > But looking more at the code I need to port, an interpreter, I think > the main issue is that the interpreter relies on sigvtalarm as > a way to preempt the interpreted program while allowing > the user program to use only sigalarm. So more generally > the problem is how can I have two alarms in plan9? I see only > one alarm signal in ape, SIGALRM. There is no SIGVTALRM. >=20 >=20 >=20 >> On Apr 29, 2015, at 9:47 AM, erik quanstrom wr= ote: >>=20 >> On Tue Apr 28 21:30:24 PDT 2015, aryx.padator@gmail.com wrote: >>> Hi, >>>=20 >>> I=E2=80=99m trying to port some code to plan9 using APE >>> but I can=E2=80=99t find the setitimer function in any include/ape/ f= iles. >>> What is the equivalent to setitimer under plan9? >>=20 >> if you're ok on using nsec() as your time source, select(3) as posix w= ould >> have it, will do. >>=20 >> - erik >>=20 --upas-gkqpzlzlijdbvddidutdicsgmw Content-Disposition: attachment; filename=notesy.c Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit #include #include #include void alarmhandler(void *a, char *msg) { USED(a); if(strstr(msg, "alarm") != 0) { printf("received alarm signal %s\n", msg); noted(NCONT); } } int timer(char *msg, int ms) { int pid, apid; pid = getpid(); switch (apid = fork()) { case -1: sysfatal("fork failed: %r"); case 0: sleep(ms); postnote(PNPROC, pid, msg); exits(nil); default: break; } return apid; } void main(int argc, char **argv) { int pid, t1pid, t2pid, count = 0; notify(alarmhandler); t1pid = timer("fooalarm", 750); count++; t2pid = timer("baralarm", 250); count++; alarm(500); while (count > 0) { pid = waitpid(); if (pid == t1pid) count--; if (pid == t2pid) count--; } exits(nil); } --upas-gkqpzlzlijdbvddidutdicsgmw-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Sat, 2 May 2015 08:06:56 -0700 To: 9fans@9fans.net Message-ID: <327906ef0db2d363fc57be34bfe82774@brasstown.quanstro.net> In-Reply-To: <32E4BD35-FCDC-4859-9034-82747001C411@gmail.com> References: <4A54E518-87FB-4F82-84AA-BDCBD4DB0956@gmail.com> <32E4BD35-FCDC-4859-9034-82747001C411@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] setitimer equivalent, and sigvtalarm equivalent Topicbox-Message-UUID: 4ebd64e4-ead9-11e9-9d60-3106f5b1d025 > I=E2=80=99m not sure I understand your proposal. >=20 > But looking more at the code I need to port, an interpreter, I think > the main issue is that the interpreter relies on sigvtalarm as > a way to preempt the interpreted program while allowing > the user program to use only sigalarm. So more generally > the problem is how can I have two alarms in plan9? I see only > one alarm signal in ape, SIGALRM. There is no SIGVTALRM. the standard way to do this is as the kernel does. the kernel typically keeps one highres timer (per core), and a linked list of events sorted by= alarm time. when the alarm fires, do the action associated with each alarm tha= t has passed and reload periodic timers. this is in port/portclock.c. i'm sur= e there are implementations of this algorithm elsewhere, too. - erik From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Sat, 2 May 2015 17:27:08 +0200 From: cinap_lenrek@felloff.net To: 9fans@9fans.net In-Reply-To: <327906ef0db2d363fc57be34bfe82774@brasstown.quanstro.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] setitimer equivalent, and sigvtalarm equivalent Topicbox-Message-UUID: 4ec1f572-ead9-11e9-9d60-3106f5b1d025 won't you need some kind of flow control in this? just hammering notes onto a process constantly might prevent that process from doing any progress and even stack overflow as signal handlers are reentrant on unix/ape. i remember that these timer signals where handled specially in the linux kernel when i implemented support for it in linuxemu that tries to prevent this. whats the program using interval timers for? maybe one can rewrite the program todo stuff with multiple processes instead of using signals? -- cinap From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) From: yoann padioleau In-Reply-To: <327906ef0db2d363fc57be34bfe82774@brasstown.quanstro.net> Date: Sat, 2 May 2015 11:01:11 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <4A54E518-87FB-4F82-84AA-BDCBD4DB0956@gmail.com> <32E4BD35-FCDC-4859-9034-82747001C411@gmail.com> <327906ef0db2d363fc57be34bfe82774@brasstown.quanstro.net> To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Subject: Re: [9fans] setitimer equivalent, and sigvtalarm equivalent Topicbox-Message-UUID: 4ec61dbe-ead9-11e9-9d60-3106f5b1d025 Hi, Yes I think you=E2=80=99re right. Indeed the machine has one timer interrupt and it=E2=80=99s enough for the kernel to demultiplex it over many processes who each can have different alarm requirments. Thx. > On May 2, 2015, at 8:06 AM, erik quanstrom = wrote: >=20 >> I=E2=80=99m not sure I understand your proposal. >>=20 >> But looking more at the code I need to port, an interpreter, I think >> the main issue is that the interpreter relies on sigvtalarm as >> a way to preempt the interpreted program while allowing >> the user program to use only sigalarm. So more generally >> the problem is how can I have two alarms in plan9? I see only >> one alarm signal in ape, SIGALRM. There is no SIGVTALRM. >=20 > the standard way to do this is as the kernel does. the kernel = typically > keeps one highres timer (per core), and a linked list of events sorted = by alarm > time. when the alarm fires, do the action associated with each alarm = that has > passed and reload periodic timers. this is in port/portclock.c. i'm = sure there > are implementations of this algorithm elsewhere, too. >=20 > - erik >=20