Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am in college and in one of my classes we are given an assignment in which we are give a binary of a program and a library (Not a binary, we can edit the library). The program deadlocks at some point when it is running. The library is just an implementation of pthreads. We are suppose to make some changes in the kernel (probably add a system call or edit the current system call according to the hints given) to prevent the program from deadlocking. I don't really know where to start. I was think to keep track on the mutexes and write an algorithm to prevent deadlock in the kernel. I know pthread uses sys_clone(). So how can I keep track of the mutexes inside the kernel? Could anyone point me in a right direction?
This has to do with threads and therefore multiple process IDs, so output as much information when you start these threads, process ID being the main one.
Using system tools like "top" you can find out what process ID is stuck waiting for semaphore and then backtrack on that.
You can use either printk() or just output data to different log files to print when you obtain and give up semaphores.
That's what I've done in the past. Meanwhile also output what the processes are doing, stuff like "still running", but use a delay for obvious reasons on that one.
I'm half guessing that the library is just a distraction. What kind of library is not binary and that you can edit by the way? Never heard of that. Do you link your code with it, or is it merely a script of some type?
You might not be able to do anything about the deadlock...
Deadlocks are caused by bugs in the application. You can't fix that by changing the kernel.
An additional problem is that adding code to the library can change the timing - and that in turn changes the timing of the deadlock. It may not even happen.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.