anchao commented on code in PR #13018: URL: https://github.com/apache/nuttx/pull/13018#discussion_r1724744669
########## sched/irq/irq_attach_thread.c: ########## @@ -0,0 +1,214 @@ +/**************************************************************************** + * sched/irq/irq_attach_thread.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <errno.h> +#include <stdio.h> + +#include <nuttx/irq.h> +#include <nuttx/kthread.h> + +#include "irq/irq.h" +#include "sched/sched.h" + +/**************************************************************************** + * Privte Types + ****************************************************************************/ + +/* This is the type of the list of interrupt handlers, one for each IRQ. + * This type provided all of the information necessary to irq_dispatch to + * transfer control to interrupt handlers after the occurrence of an + * interrupt. + */ + +struct irq_thread_info_s +{ + xcpt_t handler; /* Address of the interrupt handler */ + xcpt_t isrthread; /* Address of the interrupt thread handler */ + FAR void *arg; /* The argument provided to the interrupt handler. */ + sem_t sem; /* irq sem used to notify irq thread */ + pid_t threadid; /* irq threadid */ +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct irq_thread_info_s g_irq_thread_vector[NR_IRQS]; Review Comment: > The current nuttx design initializes time interrupts before the scheduling unlock. This issue arises if the time interrupts use isrthread. So you enabled irq before irqthread started? Shouldn't irq be enabled after the thread is started? > As for the g_irq_thread_vector datasize, I have another optimization patch that will configure the maximum number of global arrays based on the actually used number of interrupts, rather than relying on irq numbers. If your implementation still depends on `static arrays` or `dynamic heap`s (mallloc?), then you don't need to submit it, the stack alloc will be more elegant. ########## sched/irq/irq_attach_thread.c: ########## @@ -0,0 +1,214 @@ +/**************************************************************************** + * sched/irq/irq_attach_thread.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#include <errno.h> +#include <stdio.h> + +#include <nuttx/irq.h> +#include <nuttx/kthread.h> + +#include "irq/irq.h" +#include "sched/sched.h" + +/**************************************************************************** + * Privte Types + ****************************************************************************/ + +/* This is the type of the list of interrupt handlers, one for each IRQ. + * This type provided all of the information necessary to irq_dispatch to + * transfer control to interrupt handlers after the occurrence of an + * interrupt. + */ + +struct irq_thread_info_s +{ + xcpt_t handler; /* Address of the interrupt handler */ + xcpt_t isrthread; /* Address of the interrupt thread handler */ + FAR void *arg; /* The argument provided to the interrupt handler. */ + sem_t sem; /* irq sem used to notify irq thread */ + pid_t threadid; /* irq threadid */ +}; + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct irq_thread_info_s g_irq_thread_vector[NR_IRQS]; Review Comment: > The current nuttx design initializes time interrupts before the scheduling unlock. This issue arises if the time interrupts use isrthread. So you enabled irq before irqthread started? Shouldn't irq be enabled after the thread is started? > As for the g_irq_thread_vector datasize, I have another optimization patch that will configure the maximum number of global arrays based on the actually used number of interrupts, rather than relying on irq numbers. If your implementation still depends on `static arrays` or `dynamic heap`s (mallloc?), then you don't need to submit it, the stack alloc will be more elegant. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
