* [9fans] setitimer equivalent @ 2015-04-29 4:28 yoann padioleau 2015-04-29 4:38 ` James A. Robinson 2015-04-29 16:47 ` erik quanstrom 0 siblings, 2 replies; 11+ messages in thread From: yoann padioleau @ 2015-04-29 4:28 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs Hi, I’m trying to port some code to plan9 using APE but I can’t find the setitimer function in any include/ape/ files. What is the equivalent to setitimer under plan9? ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] setitimer equivalent 2015-04-29 4:28 [9fans] setitimer equivalent yoann padioleau @ 2015-04-29 4:38 ` James A. Robinson 2015-04-29 4:55 ` lucio 2015-04-29 16:47 ` erik quanstrom 1 sibling, 1 reply; 11+ messages in thread From: James A. Robinson @ 2015-04-29 4:38 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs [-- Attachment #1: Type: text/plain, Size: 465 bytes --] 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 <aryx.padator@gmail.com> wrote: > Hi, > > I’m trying to port some code to plan9 using APE > but I can’t find the setitimer function in any include/ape/ files. > What is the equivalent to setitimer under plan9? > > > [-- Attachment #2: Type: text/html, Size: 792 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] setitimer equivalent 2015-04-29 4:38 ` James A. Robinson @ 2015-04-29 4:55 ` lucio 2015-04-29 5:19 ` James A. Robinson 0 siblings, 1 reply; 11+ messages in thread From: lucio @ 2015-04-29 4:55 UTC (permalink / raw) To: 9fans > 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. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] setitimer equivalent 2015-04-29 4:55 ` lucio @ 2015-04-29 5:19 ` James A. Robinson 2015-04-29 6:38 ` lucio 0 siblings, 1 reply; 11+ messages in thread From: James A. Robinson @ 2015-04-29 5:19 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs [-- Attachment #1: Type: text/plain, Size: 700 bytes --] 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 <lucio@proxima.alt.za> 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. > > > [-- Attachment #2: Type: text/html, Size: 963 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] setitimer equivalent 2015-04-29 5:19 ` James A. Robinson @ 2015-04-29 6:38 ` lucio 0 siblings, 0 replies; 11+ messages in thread From: lucio @ 2015-04-29 6:38 UTC (permalink / raw) To: 9fans > 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. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] setitimer equivalent 2015-04-29 4:28 [9fans] setitimer equivalent yoann padioleau 2015-04-29 4:38 ` James A. Robinson @ 2015-04-29 16:47 ` erik quanstrom 2015-05-01 3:21 ` [9fans] setitimer equivalent, and sigvtalarm equivalent yoann padioleau 1 sibling, 1 reply; 11+ messages in thread From: erik quanstrom @ 2015-04-29 16:47 UTC (permalink / raw) To: 9fans On Tue Apr 28 21:30:24 PDT 2015, aryx.padator@gmail.com wrote: > Hi, > > I’m trying to port some code to plan9 using APE > but I can’t find the setitimer function in any include/ape/ files. > What is the equivalent to setitimer under plan9? if you're ok on using nsec() as your time source, select(3) as posix would have it, will do. - erik ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] setitimer equivalent, and sigvtalarm equivalent 2015-04-29 16:47 ` erik quanstrom @ 2015-05-01 3:21 ` yoann padioleau 2015-05-01 7:17 ` Skip Tavakkolian 2015-05-02 15:06 ` erik quanstrom 0 siblings, 2 replies; 11+ messages in thread From: yoann padioleau @ 2015-05-01 3:21 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs Hi, I’m 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 <quanstro@quanstro.net> wrote: > > On Tue Apr 28 21:30:24 PDT 2015, aryx.padator@gmail.com wrote: >> Hi, >> >> I’m trying to port some code to plan9 using APE >> but I can’t find the setitimer function in any include/ape/ files. >> What is the equivalent to setitimer under plan9? > > if you're ok on using nsec() as your time source, select(3) as posix would > have it, will do. > > - erik > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] setitimer equivalent, and sigvtalarm equivalent 2015-05-01 3:21 ` [9fans] setitimer equivalent, and sigvtalarm equivalent yoann padioleau @ 2015-05-01 7:17 ` Skip Tavakkolian 2015-05-02 15:06 ` erik quanstrom 1 sibling, 0 replies; 11+ messages in thread From: Skip Tavakkolian @ 2015-05-01 7:17 UTC (permalink / raw) To: 9fans [-- Attachment #1: Type: text/plain, Size: 1253 bytes --] 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, > > I’m 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 <quanstro@quanstro.net> wrote: >> >> On Tue Apr 28 21:30:24 PDT 2015, aryx.padator@gmail.com wrote: >>> Hi, >>> >>> I’m trying to port some code to plan9 using APE >>> but I can’t find the setitimer function in any include/ape/ files. >>> What is the equivalent to setitimer under plan9? >> >> if you're ok on using nsec() as your time source, select(3) as posix would >> have it, will do. >> >> - erik >> [-- Attachment #2: notesy.c --] [-- Type: text/plain, Size: 798 bytes --] #include <u.h> #include <libc.h> #include <stdio.h> 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); } ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] setitimer equivalent, and sigvtalarm equivalent 2015-05-01 3:21 ` [9fans] setitimer equivalent, and sigvtalarm equivalent yoann padioleau 2015-05-01 7:17 ` Skip Tavakkolian @ 2015-05-02 15:06 ` erik quanstrom 2015-05-02 15:27 ` cinap_lenrek 2015-05-02 18:01 ` yoann padioleau 1 sibling, 2 replies; 11+ messages in thread From: erik quanstrom @ 2015-05-02 15:06 UTC (permalink / raw) To: 9fans > I’m 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. 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. - erik ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] setitimer equivalent, and sigvtalarm equivalent 2015-05-02 15:06 ` erik quanstrom @ 2015-05-02 15:27 ` cinap_lenrek 2015-05-02 18:01 ` yoann padioleau 1 sibling, 0 replies; 11+ messages in thread From: cinap_lenrek @ 2015-05-02 15:27 UTC (permalink / raw) To: 9fans 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] setitimer equivalent, and sigvtalarm equivalent 2015-05-02 15:06 ` erik quanstrom 2015-05-02 15:27 ` cinap_lenrek @ 2015-05-02 18:01 ` yoann padioleau 1 sibling, 0 replies; 11+ messages in thread From: yoann padioleau @ 2015-05-02 18:01 UTC (permalink / raw) To: Fans of the OS Plan 9 from Bell Labs Hi, Yes I think you’re right. Indeed the machine has one timer interrupt and it’s 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 <quanstro@quanstro.net> wrote: > >> I’m 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. > > 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. > > - erik > ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-05-02 18:01 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-04-29 4:28 [9fans] setitimer equivalent yoann padioleau 2015-04-29 4:38 ` James A. Robinson 2015-04-29 4:55 ` lucio 2015-04-29 5:19 ` James A. Robinson 2015-04-29 6:38 ` lucio 2015-04-29 16:47 ` erik quanstrom 2015-05-01 3:21 ` [9fans] setitimer equivalent, and sigvtalarm equivalent yoann padioleau 2015-05-01 7:17 ` Skip Tavakkolian 2015-05-02 15:06 ` erik quanstrom 2015-05-02 15:27 ` cinap_lenrek 2015-05-02 18:01 ` yoann padioleau
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).