LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 11-03-2015, 06:46 PM   #1
samarth2892
LQ Newbie
 
Registered: Nov 2015
Posts: 2

Rep: Reputation: Disabled
Question Dead lock prevention inside the linux kernel.


Hello,

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?

Thanks
 
Old 11-03-2015, 07:28 PM   #2
Rinndalir
Member
 
Registered: Sep 2015
Posts: 733

Rep: Reputation: Disabled
Since you have the library you need to inspect that library and try to understand it.
You also need to find where the binary deadlocks.

Also how do you know it deadlocks? What hints are you given and why don't they help you to go in the right direction?
 
Old 11-03-2015, 07:55 PM   #3
samarth2892
LQ Newbie
 
Registered: Nov 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
It is in the project description that the program deadlocks. Prof and TA are not very useful for some reason, whole class is having problems.

I and other classmates examined the library but it is not the problem because it just uses pthreads without applying any logic or algorithms.

So is it possible to monitor mutex by making a kernel module?
 
Old 11-04-2015, 07:58 AM   #4
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
Have you tried 'strace'?
 
Old 11-04-2015, 08:41 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
It's possible to debug just using printk()

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?
 
Old 11-06-2015, 04:36 AM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Caps Lock & Scroll Lock lights blinking (Not a Kernel Panic) Amanda_L Linux - Software 1 01-24-2014 06:58 PM
to find dead lock sunil80 Linux - Newbie 2 03-07-2013 02:42 AM
LXer: What's Really Inside the Red Hat Linux Kernel? LXer Syndicated Linux News 0 06-02-2010 06:50 PM
Hard lock plus Caps and Scroll Lock flashing (kernel panic?) TiredOfThis Linux - General 4 12-11-2007 07:35 PM
Inside linux kernel module compilation and loading nandac Programming 5 03-12-2007 12:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration