Re: [9fans] syscall silently kill processes

2022-06-29 Thread adr
On Tue, 28 Jun 2022, adr wrote: It's just to play with it, note that onnote should be just passed once. I'll post another patch if things work ok. Here it is. I'm doing sysfatal when malloc fails to be coherent with the rest of libthread, but I don't think that's a good approach. When those

Re: [9fans] syscall silently kill processes

2022-06-28 Thread adr
On Tue, 28 Jun 2022, andrey100100...@gmail.com wrote: Thanks for the patch. It's just to play with it, note that onnote should be just passed once. I'll post another patch if things work ok. adr -- 9fans: 9fans Permalink:

Re: [9fans] syscall silently kill processes

2022-06-28 Thread andrey100100100
В Вт, 28/06/2022 в 15:28 +, adr пишет: > Andrey, if you want to use different note handlers per process (with > a big > number of processes) using libthread, this may be helpful. > > The idea is this: > > An array of handlers for all processes which can be changed by all > processes. > When

Re: [9fans] syscall silently kill processes

2022-06-28 Thread adr
On Tue, 28 Jun 2022, adr wrote: This just evade going through the arrays twice. For the current value of NFN it doesn't make too much a difference, note that this structures are locked. It just was hurting my eyes. Sorry for the noise, bad patch. --- /tmp/main.c +++ /sys/src/libthread/main.c

Re: [9fans] syscall silently kill processes

2022-06-28 Thread adr
On Tue, 28 Jun 2022, adr wrote: Andrey, if you want to use different note handlers per process (with a big number of processes) using libthread, this may be helpful. The idea is this: An array of handlers for all processes which can be changed by all processes. When a note is received by a

Re: [9fans] syscall silently kill processes

2022-06-28 Thread ori
Quoth adr : > Andrey, if you want to use different note handlers per process (with a big > number of processes) using libthread, this may be helpful. > > The idea is this: > > An array of handlers for all processes which can be changed by all processes. > When a note is received by a process,

Re: [9fans] syscall silently kill processes

2022-06-28 Thread adr
Andrey, if you want to use different note handlers per process (with a big number of processes) using libthread, this may be helpful. The idea is this: An array of handlers for all processes which can be changed by all processes. When a note is received by a process, this array takes priority.

Re: [9fans] syscall silently kill processes

2022-06-21 Thread andrey100100100
В Вт, 21/06/2022 в 11:26 +, adr пишет: > On Tue, 21 Jun 2022, andrey100100...@gmail.com wrote: > > ? ??, 20/06/2022 ? 15:29 -0700, Skip Tavakkolian ?: > > > It's cleaner to use channels with separate io and timer threads > > > that > > > do their syscalls via ioproc; this one doesn't

Re: [9fans] syscall silently kill processes

2022-06-21 Thread adr
On Tue, 21 Jun 2022, andrey100100...@gmail.com wrote: For example, let's remove note.c. You could obtain the same result Just for clarity, you actually don't need to remove note.c to do what I said below. in your example (all processes using the same handler) using atnotify because the

Re: [9fans] syscall silently kill processes

2022-06-21 Thread andrey100100100
В Вт, 21/06/2022 в 11:26 +, adr пишет: > On Tue, 21 Jun 2022, andrey100100...@gmail.com wrote: > > ? ??, 20/06/2022 ? 15:29 -0700, Skip Tavakkolian ?: > > > It's cleaner to use channels with separate io and timer threads > > > that > > > do their syscalls via ioproc; this one doesn't

Re: [9fans] syscall silently kill processes

2022-06-21 Thread adr
On Tue, 21 Jun 2022, andrey100100...@gmail.com wrote: ? ??, 20/06/2022 ? 15:29 -0700, Skip Tavakkolian ?: It's cleaner to use channels with separate io and timer threads that do their syscalls via ioproc; this one doesn't require any changes to libthread:

Re: [9fans] syscall silently kill processes

2022-06-21 Thread adr
On Mon, 20 Jun 2022, Skip Tavakkolian wrote: It's cleaner to use channels with separate io and timer threads that do their syscalls via ioproc; this one doesn't require any changes to libthread: https://gist.github.com/9nut/aaa9b9b6a22d69996b75ccdc6e615c61 Nice example, but I strongly

Re: [9fans] syscall silently kill processes

2022-06-21 Thread andrey100100100
В Пн, 20/06/2022 в 15:29 -0700, Skip Tavakkolian пишет: > It's cleaner to use channels with separate io and timer threads that > do their syscalls via ioproc; this one doesn't require any changes to > libthread: > > https://gist.github.com/9nut/aaa9b9b6a22d69996b75ccdc6e615c61 Thanks for the

Re: [9fans] syscall silently kill processes

2022-06-20 Thread Skip Tavakkolian
It's cleaner to use channels with separate io and timer threads that do their syscalls via ioproc; this one doesn't require any changes to libthread: https://gist.github.com/9nut/aaa9b9b6a22d69996b75ccdc6e615c61 On Mon, Jun 20, 2022 at 8:57 AM wrote: > > В Пн, 20/06/2022 в 05:59 +, adr

Re: [9fans] syscall silently kill processes

2022-06-20 Thread andrey100100100
В Пн, 20/06/2022 в 05:59 +, adr пишет: > On Mon, 20 Jun 2022, adr wrote: > > But I have something in mind for a case like > > this, when all the processes are going to use the same handler > > (that's why I was asking). Let me play with it a litle before I > > share it. > > Ok, the idea is

Re: [9fans] syscall silently kill processes (fwd)

2022-06-20 Thread adr
The last mail got screwed, I'm resending this for clarity. /sys/src/libthread/sched.c: [...] if(t == nil){ _threaddebug(DBGSCHED, "all threads gone; exiting"); cancelnotes(p->pid); _schedexit(p); }

Re: [9fans] syscall silently kill processes

2022-06-20 Thread adr
On Mon, 20 Jun 2022, adr wrote: But I have something in mind for a case like this, when all the processes are going to use the same handler (that's why I was asking). Let me play with it a litle before I share it. Ok, the idea is this: If in is bigger than zero in threadnotify(int (*f)(void*,

Re: [9fans] syscall silently kill processes

2022-06-19 Thread andrey100100100
В Пн, 20/06/2022 в 04:41 +, adr пишет: > On Mon, 20 Jun 2022, andrey100100...@gmail.com wrote: > > The note 'alarm' is needed to interrupt the system call on timeout > > since system calls to lan 9 can be of a network nature, a notes is > > indispensable. > > A great example of this is the

Re: [9fans] syscall silently kill processes

2022-06-19 Thread adr
On Mon, 20 Jun 2022, andrey100100...@gmail.com wrote: The note 'alarm' is needed to interrupt the system call on timeout since system calls to lan 9 can be of a network nature, a notes is indispensable. A great example of this is the read() system call on a udp-connection. How else can this

Re: [9fans] syscall silently kill processes

2022-06-19 Thread andrey100100100
В Пн, 20/06/2022 в 00:22 +0300, andrey100100...@gmail.com пишет: > В Вс, 19/06/2022 в 16:41 +, adr пишет: > > On Sun, 19 Jun 2022, andrey100100...@gmail.com wrote: > > > Yes, you were absolutely right, the thread library needs some > > > work. > > > > > > It is impossible to use multiple

Re: [9fans] syscall silently kill processes

2022-06-19 Thread andrey100100100
В Вс, 19/06/2022 в 16:41 +, adr пишет: > On Sun, 19 Jun 2022, andrey100100...@gmail.com wrote: > > Yes, you were absolutely right, the thread library needs some work. > > > > It is impossible to use multiple processes with notes, due to the > > exhaustion of the NFN limit. > > Andrej, what

Re: [9fans] syscall silently kill processes

2022-06-19 Thread adr
On Sun, 19 Jun 2022, andrey100100...@gmail.com wrote: Yes, you were absolutely right, the thread library needs some work. It is impossible to use multiple processes with notes, due to the exhaustion of the NFN limit. Andrej, what are you going to do with alarm in the real thing? You could

Re: [9fans] syscall silently kill processes

2022-06-19 Thread andrey100100100
В Вс, 19/06/2022 в 10:32 +, adr пишет: > On Sun, 19 Jun 2022, andrey100100...@gmail.com wrote: > > No way. All processes must run simultaneously. > > NFN limit cannot be bypassed. > > Yeah, that's why I said it was silly: > > > > The solution is obvious, cancel the process' handlers before it

Re: [9fans] syscall silently kill processes

2022-06-19 Thread andrey100100100
В Вс, 19/06/2022 в 14:40 +0300, andrey100100...@gmail.com пишет: > В Вс, 19/06/2022 в 10:32 +, adr пишет: > > On Sun, 19 Jun 2022, andrey100100...@gmail.com wrote: > > > No way. All processes must run simultaneously. > > > NFN limit cannot be bypassed. > > > > Yeah, that's why I said it was

Re: [9fans] syscall silently kill processes

2022-06-19 Thread andrey100100100
В Вс, 19/06/2022 в 10:32 +, adr пишет: > On Sun, 19 Jun 2022, andrey100100...@gmail.com wrote: > > No way. All processes must run simultaneously. > > NFN limit cannot be bypassed. > > Yeah, that's why I said it was silly: > > > > The solution is obvious, cancel the process' handlers before it

Re: [9fans] syscall silently kill processes

2022-06-19 Thread adr
On Sun, 19 Jun 2022, andrey100100...@gmail.com wrote: No way. All processes must run simultaneously. NFN limit cannot be bypassed. Yeah, that's why I said it was silly: The solution is obvious, cancel the process' handlers before it exits so we don't run out of space. This was really

Re: [9fans] syscall silently kill processes

2022-06-19 Thread andrey100100100
В Вс, 19/06/2022 в 05:01 +, adr пишет: > On Sun, 19 Jun 2022, adr wrote: > > The solution is obvious, cancel the process' handlers before it > > exits so we don't run out of space. > > This was really silly... > > > Now, is there any reason to not do that in threadexits() when it > >

Re: [9fans] syscall silently kill processes

2022-06-19 Thread Jacob Moody
On 6/18/22 23:54, adr wrote: > On Sat, 18 Jun 2022, Jacob Moody wrote: >> I've attempted to reproduce it, trying to remove the libthread/notify >> factors. I've come up with this: >> >> #include >> #include >> >> static void >> proc_udp(void*) >> { >>char resp[512]; >>char req[]

Re: [9fans] syscall silently kill processes

2022-06-18 Thread adr
On Sat, 18 Jun 2022, Jacob Moody wrote: I've attempted to reproduce it, trying to remove the libthread/notify factors. I've come up with this: #include #include static void proc_udp(void*) { char resp[512]; char req[] = "request"; int fd; int n; int pid;

Re: [9fans] syscall silently kill processes

2022-06-18 Thread adr
On Sun, 19 Jun 2022, adr wrote: The solution is obvious, cancel the process' handlers before it exits so we don't run out of space. This was really silly... Now, is there any reason to not do that in threadexits() when it terminates the process? Shouldn't threadnotify() cancel only the

Re: [9fans] syscall silently kill processes

2022-06-18 Thread adr
Oh man... how silly, I know what's going on. We are using processes not threads, so although we are sharing the same array of handlers, they are registered for different processes. When the array is full the next processes fail to register handlers _for_them_ so as andrey rightly said, the

Re: [9fans] syscall silently kill processes

2022-06-18 Thread andrey100100100
В Сб, 18/06/2022 в 09:22 +, adr пишет: > On Sat, 18 Jun 2022, adr wrote: > > > On Sat, 18 Jun 2022, andrey100100...@gmail.com wrote: > > > > > - > > > > > > cpu% 6.out | grep end | wc -l > > >     33 > > > > > > > > > Problem in unregistered

Re: [9fans] syscall silently kill processes

2022-06-18 Thread andrey100100100
В Сб, 18/06/2022 в 06:53 -0600, Jacob Moody пишет: > On 6/18/22 03:22, adr wrote: > > On Sat, 18 Jun 2022, adr wrote: > > > > > On Sat, 18 Jun 2022, andrey100100...@gmail.com wrote: > > > > > > > - > > > > > > > > cpu% 6.out | grep end | wc -l > > > >

Re: [9fans] syscall silently kill processes

2022-06-18 Thread andrey100100100
В Сб, 18/06/2022 в 08:37 +, adr пишет: > On Sat, 18 Jun 2022, andrey100100...@gmail.com wrote: > > > - > > > > cpu% 6.out | grep end | wc -l > >     33 > > > > > > Problem in unregistered handlers. > > But unregistered handlers shouldn't be a

Re: [9fans] syscall silently kill processes

2022-06-18 Thread Jacob Moody
On 6/18/22 03:22, adr wrote: > On Sat, 18 Jun 2022, adr wrote: > >> On Sat, 18 Jun 2022, andrey100100...@gmail.com wrote: >> >>> - >>> >>> cpu% 6.out | grep end | wc -l >>> 33 >>> >>> >>> Problem in unregistered handlers. >> >> But unregistered

Re: [9fans] syscall silently kill processes

2022-06-18 Thread adr
On Sat, 18 Jun 2022, adr wrote: On Sat, 18 Jun 2022, andrey100100...@gmail.com wrote: - cpu% 6.out | grep end | wc -l 33 Problem in unregistered handlers. But unregistered handlers shouldn't be a problem. The process is been killed when

Re: [9fans] syscall silently kill processes

2022-06-18 Thread adr
On Sat, 18 Jun 2022, andrey100100...@gmail.com wrote: - cpu% 6.out | grep end | wc -l 33 Problem in unregistered handlers. But unregistered handlers shouldn't be a problem. The process is been killed when alarm sends the note. That's why the

Re: [9fans] syscall silently kill processes

2022-06-18 Thread andrey100100100
В Пт, 17/06/2022 в 21:15 +, adr пишет: > On Fri, 17 Jun 2022, andrey100100...@gmail.com wrote: > > Seems like noted() call not needed in user code. > > noted() is only needed when using the syscall notify, when using > atnotify() (or threadnotify) you don't need it, as it is said in >

Re: [9fans] syscall silently kill processes

2022-06-17 Thread adr
On Fri, 17 Jun 2022, andrey100100...@gmail.com wrote: Seems like noted() call not needed in user code. noted() is only needed when using the syscall notify, when using atnotify() (or threadnotify) you don't need it, as it is said in notify(2) and you did correctly in your first example.

Re: [9fans] syscall silently kill processes

2022-06-17 Thread Jacob Moody
On 6/17/22 12:48, andrey100100...@gmail.com wrote: > В Пт, 17/06/2022 в 10:11 -0600, Jacob Moody пишет: >> On 6/17/22 09:06, andrey100100...@gmail.com wrote: >>> В Пт, 17/06/2022 в 08:11 -0600, Jacob Moody пишет: On 6/17/22 07:46, Thaddeus Woskowiak wrote: > I believe threadnotify()

Re: [9fans] syscall silently kill processes

2022-06-17 Thread andrey100100100
В Пт, 17/06/2022 в 10:11 -0600, Jacob Moody пишет: > On 6/17/22 09:06, andrey100100...@gmail.com wrote: > > В Пт, 17/06/2022 в 08:11 -0600, Jacob Moody пишет: > > > On 6/17/22 07:46, Thaddeus Woskowiak wrote: > > > > I believe threadnotify() should be called from threadmain() to > > > > properly

Re: [9fans] syscall silently kill processes

2022-06-17 Thread adr
On Fri, 17 Jun 2022, Skip Tavakkolian wrote: Thanks to Douglas Adams, I think '42' might be a more obvious magic number for a clue: % 8c udpflood.c && 8l -o udpflood udpflood.8 && ./udpflood | grep end | wc -l 42 % grep 42 /sys/src/libthread/note.c #define NFN 42 I don't understand, why

Re: [9fans] syscall silently kill processes

2022-06-17 Thread Skip Tavakkolian
Thanks to Douglas Adams, I think '42' might be a more obvious magic number for a clue: % 8c udpflood.c && 8l -o udpflood udpflood.8 && ./udpflood | grep end | wc -l 42 % grep 42 /sys/src/libthread/note.c #define NFN 42 On Fri, Jun 17, 2022 at 9:11 AM Skip Tavakkolian wrote: > > it's worth

Re: [9fans] syscall silently kill processes

2022-06-17 Thread Jacob Moody
On 6/17/22 09:06, andrey100100...@gmail.com wrote: > В Пт, 17/06/2022 в 08:11 -0600, Jacob Moody пишет: >> On 6/17/22 07:46, Thaddeus Woskowiak wrote: >>> I believe threadnotify() should be called from threadmain() to >>> properly register the handler in the rendez group >> >> This is incorrect,

Re: [9fans] syscall silently kill processes

2022-06-17 Thread Skip Tavakkolian
it's worth grepping for persistent magic constants: % grep 33 /sys/src/libthread/*.[ch] /sys/src/libthread/note.c:#define NFN 33 On Fri, Jun 17, 2022 at 9:08 AM Skip Tavakkolian wrote: > > interesting catch. it seems to be a tunable limit. > > % grep NFN /sys/src/libthread/note.c > #define NFN

Re: [9fans] syscall silently kill processes

2022-06-17 Thread Skip Tavakkolian
interesting catch. it seems to be a tunable limit. % grep NFN /sys/src/libthread/note.c #define NFN 33 static int (*onnote[NFN])(void*, char*); static int onnotepid[NFN]; for(i=0; i wrote: > > В Пт, 17/06/2022 в 08:11 -0600, Jacob Moody пишет: > > On 6/17/22 07:46, Thaddeus Woskowiak wrote: > > >

Re: [9fans] syscall silently kill processes

2022-06-17 Thread andrey100100100
В Пт, 17/06/2022 в 08:11 -0600, Jacob Moody пишет: > On 6/17/22 07:46, Thaddeus Woskowiak wrote: > > I believe threadnotify() should be called from threadmain() to > > properly register the handler in the rendez group > > This is incorrect, according to thread(2): > > "The thread library depends

Re: [9fans] syscall silently kill processes

2022-06-17 Thread Thaddeus Woskowiak
On Fri, Jun 17, 2022 at 10:13 AM Jacob Moody wrote: > > On 6/17/22 07:46, Thaddeus Woskowiak wrote: > > I believe threadnotify() should be called from threadmain() to > > properly register the handler in the rendez group > > This is incorrect, according to thread(2): > > "The thread library

Re: [9fans] syscall silently kill processes

2022-06-17 Thread Jacob Moody
On 6/17/22 07:46, Thaddeus Woskowiak wrote: > I believe threadnotify() should be called from threadmain() to > properly register the handler in the rendez group This is incorrect, according to thread(2): "The thread library depends on all procs being in the same rendezvous group" The issue here

Re: [9fans] syscall silently kill processes

2022-06-17 Thread Thaddeus Woskowiak
I believe threadnotify() should be called from threadmain() to properly register the handler in the rendez group. On Fri, Jun 17, 2022 at 5:39 AM wrote: > > Hi all! > > Strange behavior of syscall 'read' with signal 'alarm' in followed > simple program (ip/port - not matter): > >

[9fans] syscall silently kill processes

2022-06-17 Thread andrey100100100
Hi all! Strange behavior of syscall 'read' with signal 'alarm' in followed simple program (ip/port - not matter): --- #include #include #include static int handler_alarm(void *, char *msg) { if(strstr(msg, "alarm"))