News for hackers. Stuff that matters.
Re:Let's write a setjmp by stevefan1999 on Sunday February 12, 2023 @10:13AM (#34763390)
I wonder if setjmp/longjmp can be implemented in hardware, i.e. introduce an instruction set that points, save and switch the current registers called register window that can be switched by saving a pointer.

This way both setjmp and longjmp are basically few cycles and exception handling would be hella fast.

Re:Let's write a setjmp by snarfy on Sunday February 12, 2023 @10:24AM (#34763484)
Intel has e.g. push all/pop all instructions. It doesn't save everything needed for setjmp/longjmp (like fpu state) but does a decent job.
Re:Let's write a setjmp by CalChris on Sunday February 12, 2023 @01:33PM (#34765404)
The DEC VAX-11 instruction set had SVPCTX and LDPCTX for the kernel which made context switch simple. It had queue instructions which made rescheduling simple. This was basically:

  SETIPL
  SVPCTX
  INSQUE
  FFS
  REMQUE
  LDPCTX
  SETIPL
Yeah, there was a little more. See page 188 of ... http://bitsavers.informatik.uni-stuttgart.de/pdf/dec/vax/vms...