On Wed, 4 Jun 2025 14:46:27 GMT, Johannes Bechberger <jbechber...@openjdk.org> 
wrote:

>> Sorry where does it say that? I think you are looking at the example in that 
>> page which makes use of sival_ptr in the signal handler. In that example 
>> reading from that timer address in the handler is valid but for us we would 
>> be accessing invalid memory. Plus we are not really reading it.
>
> Why would we be accessing invalid memory?

Which differences to the example code are you seeing?


 sev.sigev_notify = SIGEV_SIGNAL;
           sev.sigev_signo = SIG;
           sev.sigev_value.sival_ptr = &timerid;
           if (timer_create(CLOCKID, &sev, &timerid) == -1)
               errExit("timer_create");

           printf("timer ID is %#jx\n", (uintmax_t) timerid);

           /* Start the timer. */

           freq_nanosecs = atoll(argv[2]);
           its.it_value.tv_sec = freq_nanosecs / 1000000000;
           its.it_value.tv_nsec = freq_nanosecs % 1000000000;
           its.it_interval.tv_sec = its.it_value.tv_sec;
           its.it_interval.tv_nsec = its.it_value.tv_nsec;



Is similar to:


 ((int*)&sev.sigev_notify)[1] = thread->osthread()->thread_id();
  clockid_t clock;
  int err = pthread_getcpuclockid(thread->osthread()->pthread_id(), &clock);
  if (err != 0) {
    log_error(jfr)("Failed to get clock for thread sampling: %s", 
os::strerror(err));
    return false;
  }
  if (timer_create(clock, &sev, &t) < 0) {
    return false;
  }
  int64_t period = get_sampling_period();
  if (period != 0) {
    set_timer_time(t, period);
  }

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25302#discussion_r2126810984

Reply via email to