Trigger interrupts from device?

I am using persistent thread model with threads never exiting. The persistent threads periodically does a handshake with host using host pinned memory. So the execution flow is something like this:

Host threads:            Device THreads:
launch kernel
             ------------>
                         start running
                         do foo()
keep spinning (polling)  ...
till device tells it is  indicate to host that foo() is done
done doing foo()         (write to pinned memory)
             <------------
do bar()                 keep doing foo()

The issue with above model is that host threads basically need to use polling (spinning). Is there a method to convert this polling to blocking? (Provided persistent threads can’t exit) I am okay with ugly hacks also.