In this post let us dwelve deeper into how python threads are implemented in linux. Open the file Python/thread.c and observe how different headers are included based on the implementation of the thread library in the OS. On linux we use pthreads. So open the file Python/thread_pthread.h.

Insert a breakpoint on line number 172.

Open the debugger and insert the following statements:

def threadFunc():

print “hello”

import thread

thread.start_new_thread ( threadFunc, () )

See how the thread is initialized and created and spawned to execute the function.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s