Skip to content

Conversation

@wangchdo
Copy link
Contributor

Fix build and runtime issues when signals all disabled.

Summary

This PR fixes dependency issues when signals are all disabled

Impact

Fix dependency issues when signals are all disabled, no impact to any existing functions

Testing

ostest passed on rv-virt:smp64

disable all signals

image

ostest passed log

NuttShell (NSH)
nsh> 
nsh> uname -a
NuttX 0.0.0 02cfe5cf75-dirty Jan 15 2026 16:37:47 risc-v rv-virt
nsh> 
nsh> ostest

(...)

smp_call_test: Test start
smp_call_test: Call cpu 0, nowait
smp_call_test: Call cpu 0, wait
smp_call_test: Call cpu 1, nowait
smp_call_test: Call cpu 1, wait
smp_call_test: Call cpu 2, nowait
smp_call_test: Call cpu 2, wait
smp_call_test: Call cpu 3, nowait
smp_call_test: Call cpu 3, wait
smp_call_test: Call cpu 4, nowait
smp_call_test: Call cpu 4, wait
smp_call_test: Call cpu 5, nowait
smp_call_test: Call cpu 5, wait
smp_call_test: Call cpu 6, nowait
smp_call_test: Call cpu 6, wait
smp_call_test: Call cpu 7, nowait
smp_call_test: Call cpu 7, wait
smp_call_test: Call multi cpu, nowait
smp_call_test: Call in interrupt, wait
smp_call_test: Call multi cpu, wait
smp_call_test: Test success

Final memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena     1fc2d20  1fc2d20
ordblks         1        7
mxordblk  1fb7c78  1f709c0
uordblks     b0a8    16278
fordblks  1fb7c78  1facaa8
user_main: Exiting
ostest_main: Exiting with status 0
nsh>

CSRCS += suspend.c
endif
endif
endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move before line 49

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

list(APPEND SRCS suspend.c)
endif()
endif()
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move before line 7 and revert the change from lin3 37-40

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/* Wait for receiver thread to terminate */

#ifndef CONFIG_DISABLE_ALL_SIGNALS
pthread_kill(fwd.if_receiver, 9);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need pthread_cancel to make receiver exit? please reference the change in previous pr.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

for (tidx = 0; tidx < nthreads; tidx++)
{
#ifndef CONFIG_DISABLE_ALL_SIGNALS
pthread_kill(tid[tidx], SIGUSR1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

i8sak->eventlistener_run = false;

#ifndef CONFIG_DISABLE_ALL_SIGNALS
pthread_kill(i8sak->eventlistener_threadid, 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@wangchdo wangchdo force-pushed the enable_disable_all_signals branch from cf6a657 to e3804fa Compare January 16, 2026 02:02
#ifndef CONFIG_DISABLE_ALL_SIGNALS
pthread_kill(fwd.if_receiver, 9);
#else
pthread_cancel(fwd.if_receiver);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean update it like this? (use #ifdef CONFIG_ENABLE_ALL_SIGNALS):

#ifdef CONFIG_ENABLE_ALL_SIGNALS
  pthread_kill(fwd.if_receiver, 9);
#else
  pthread_cancel(fwd.if_receiver);
#endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like this:

#ifndef CONFIG_ENABLE_ALL_SIGNALS
  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
  pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL);
#endif

  while (1)
    {
#ifndef CONFIG_ENABLE_ALL_SIGNALS
      pthread_testcancel();
#endif

@wangchdo wangchdo force-pushed the enable_disable_all_signals branch 2 times, most recently from af94348 to 0cc5a9a Compare January 16, 2026 04:04

i8sak->eventlistener_run = false;

#ifdef CONFIG_ENABLE_ALL_SIGNALS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifdef CONFIG_ENABLE_ALL_SIGNALS
#ifdef CONFIG_DISABLE_ALL_SIGNALS
pthread_cancel(i8sak->eventlistener_threadid);
#else
pthread_kill(i8sak->eventlistener_threadid, 2);
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

FAR struct ieee802154_primitive_s *primitive = NULL;
int ret = OK;

#ifndef CONFIG_ENABLE_ALL_SIGNALS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifndef CONFIG_ENABLE_ALL_SIGNALS
#ifdef CONFIG_DISABLE_ALL_SIGNALS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


/* Wake up the receiver thread with a signal */

#ifdef CONFIG_ENABLE_ALL_SIGNALS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifdef CONFIG_ENABLE_ALL_SIGNALS
#ifndef CONFIG_DISABLE_ALL_SIGNALS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


while (i8sak->eventlistener_run)
{
#ifndef CONFIG_ENABLE_ALL_SIGNALS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifndef CONFIG_ENABLE_ALL_SIGNALS
#ifdef CONFIG_DISABLE_ALL_SIGNALS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


#ifdef CONFIG_ENABLE_ALL_SIGNALS
printf("mqueue_test: Killing receiver\n");
pthread_kill(receiver, SIGUSR1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we skip the test from build

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I removed the test from build.

return -EINVAL;
}

#ifdef CONFIG_ENABLE_ALL_SIGNALS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should skip the test in this case or modify the code to make it work really

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to remove the test from build.


for (tidx = 0; tidx < nthreads; tidx++)
{
#ifdef CONFIG_ENABLE_ALL_SIGNALS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifdef CONFIG_ENABLE_ALL_SIGNALS
#ifdef CONFIG_DISABLE_ALL_SIGNALS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

TEST_ASSERT_TRUE(test_abort);
TEST_ASSERT_TRUE(test_hang || !test_hang);

#ifndef CONFIG_ENABLE_ALL_SIGNALS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@wangchdo wangchdo force-pushed the enable_disable_all_signals branch 5 times, most recently from 66096e1 to 62f6066 Compare January 16, 2026 09:21
 Fix build and runtime issues when signals all disabled.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
@wangchdo wangchdo force-pushed the enable_disable_all_signals branch from 62f6066 to 8610764 Compare January 16, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants