12.07.2015 Views

Shared State Concurrency - Common Lisp.net

Shared State Concurrency - Common Lisp.net

Shared State Concurrency - Common Lisp.net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

current-threadThis returns the object for the current thread.alive-threadsFunctionFunctionThis returns a list of threads that are currently alive. One thread that is certain tobe a member of (alive-threads) is (current-thread).yield-processorFunctionThis is an hint to the scheduler that this is a good time to change state of the currentthread from running to ready and allow other thread to run in the processor thatthe current thread is running.TD: How does the function cl:sleep behave?TD: What about the scheduler?TD: How does the garbage collector behaves in relation to unreachable and blockedthreads?(make-thread #’(lambda ()(let ((m (make-lock)))(acquire-lock m)(condvar-wait (make-condvar m)))))Each thread has a priority, a number between −5 and +5, that is an indicationto the scheduler of how important it is that the thread be chosen to runwhen there are several threads ready and not enough CPUs for them all. Largerpriority numbers represent more important threads. This can be ignored by theimplementation.thread-priority threadFunctionThis returns the priority of thread; it is a value between −5 and +5. This can bechanged with setf. The argument for the setf form must be an integer between−5 and +5.Note that the value you specify with setf might not be the one you get back:in an implementation that does not support priorities, thread-priority mightalways return 0, for example.4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!