Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-13-2013, 02:54 PM   #1
LQ Newbie
Registered: Feb 2012
Posts: 8

Rep: Reputation: Disabled
Question Facing dependencies issues when modifying spinlock


I want to modify spin_lock & spin_unlock API in spinlock.h of I want to add a counter for each core so that every time a lock is taken on a core, its counter in incremented and decremented when spin_lock is called. At any point of time I can get lock_depth of each core.

I tried doing this by adding a per CPU variable. using
DECLARE_PER_CPU(int, crnt_lck_depth)
but to do this I had to
#include percpu.h
which inturn
#includes spinlock.h

So I did a work around by creating an array and writing into respective index, but to do this I needed the executing thread's cpu using
, again I got the same issues of dependencies.

Heres what I have done so far in spinlock.h
static int ctr_lock_depth[24];                                                       
EXPORT_SYMBOL(ctr_lock_depth);//ctr_depth is used by other module

/* from smp.h */                                                                                     
extern int raw_smp_processor_id(void);                                               
static inline void spin_lock(spinlock_t *lock)                                       
        int cpu;                                                                     
        cpu = raw_smp_processor_id();                                                
static inline void spin_unlock(spinlock_t *lock)                                     
        int cpu ;                                                                    
        cpu = raw_smp_processor_id();                                                
And these are the warning/error I get

include/linux/spinlock.h:292:1: warning: data definition has no type or storage class
include/linux/spinlock.h:292:1: warning: type defaults to ‘int’ in declaration of ‘EXPORT_SYMBOL’
include/linux/spinlock.h:292:1: warning: parameter names (without types) in function declaration
include/linux/timex.h:76:17: error: field ‘time’ has incomplete type
In file included from include/linux/ktime.h:25:0,
                 from include/linux/timer.h:5,
                 from include/linux/workqueue.h:8,
                 from include/linux/pm.h:25,
                 from /usr/src/linux-,
                 from /usr/src/linux-,
                 from include/linux/spinlock.h:62,
                 from include/linux/seqlock.h:29,
                 from include/linux/time.h:8,
                 from include/linux/stat.h:60,
                 from include/linux/module.h:10,
                 from include/linux/crypto.h:21,
                 from arch/x86/kernel/asm-offsets_64.c:8,
                 from arch/x86/kernel/asm-offsets.c:4:
include/linux/jiffies.h:257:10: warning: "NSEC_PER_SEC" is not defined
include/linux/ktime.h:84:6: error: ‘NSEC_PER_SEC’ undeclared (first use in this function)
include/linux/time.h:240:23: error: conflicting types for ‘ns_to_timeval’
include/linux/ktime.h:294:22: note: previous implicit declaration of ‘ns_to_timeval’ was here
Am getting anything wrong? Is there any other simpler way to do the same .



dependencies, kernel, linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Facing issues in RDP from Windows to Linux Rohit_4739 Linux - Newbie 3 04-18-2012 10:17 AM
facing ns2 installation issues in ubuntu 11.04 umair ahmed Linux - Newbie 4 03-07-2012 12:22 PM
Facing issues with load rules in clearcase on Unix skrishnapradeep Linux - General 1 03-10-2009 06:26 PM
LXer: What are the top 3 issues facing Gentoo? LXer Syndicated Linux News 0 02-19-2008 08:21 PM
Facing issues in Wireshark network analyzer Dthecompany Linux - Newbie 4 01-29-2008 07:53 AM > Forums > Non-*NIX Forums > Programming

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

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