Error in creating /proc file

2005-03-14 Thread sounak chakraborty
dear sir,
i am actually trying to create a thread directory in
which files will be created by the name of the thread
id
which will contain the basic information about the
thread
(similar to process concept of kernel)
but i want to the detail steps about how the kernel
implements its process information inside
the proc file so that i can do it similar kind in case
of creating for the threads.

the first basic problem is the 
according to me the 
1.the actual processes are creting in the do_fork
function and from there the 
  information is passed to the fs/proc  in the
functions present in the generic and base.c
  am i currect or the fs/proc is collecting the data
from the current 

  but in this case i was applying a shortcuts as i was
waiting for any proc file in the kernel to be written 
  during startup and the setting a global variable in
fs/proc/base.c after that in the
  do_fork the function waits for the global variable
to be turned on and after that calls anather function
  which creates proc files through the use of
create_proc_entry.

  but during startup the following errors are coming 
  "
*pde=
Oops: [#1]
PREEMPT
Modules link in: 
CPU: 0
EIP: 0060:[] Not tainted
EFLAGS: 00010202 (2.6.8)
EIP is at register_proc_table+0xdc/0x130

eax: ebx:c0321d40 ecx:1006
edx:c02e28c5
esi: edi: ebp:0006
esp:c7e95fb0
ds: 007b es: 007b ss:0068
 
Process Swapper(pid :1,threadinfo =c7e94000
task=c7e93670)
Stack: c03635e4 c03635e4 c03635e4 416d
00100410  
   c03a8ee8 c0321d40  c039e8ac
c0100445 007b 
   c01040e0 c01040e5  
 

   Call Trace :
 [] init+0x0/0x158 
 [] sysctl_init+0x18/0x20
 [] do_basic_setup+0xa/0x20
 [] init+0x35/0x158
 [] kernel_thread_helper+0x0/0x10
 [] kernel_thread_helper+0x5/0x10
 
 Code: 8b 78 34 85 ff 74 b7 8d b6 
   00 00 00 00 8d bc 27 00 00 
   00 00
 <0> Kernel panic : Attempted to kill init!

   "
  


  


2.if i am in a wrong way i could do the implementation
in the following manner in which the 
  kernel implements the proc system of its process
part.
  but i am really confused about that one .i need some
kind of help in that case 
  is it necessary to do all the details implementation
like inode creating which are all being done 
  in the generic and base.c  or i can simply bypass
them with   create_proc_entry

  what should i do 
  
 suggest me some architecture to implement the thread
proc system 

i can a way out 
and i cant able to understand where i am wrong
thanks in advance
sounak


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


problem with process and threads

2005-03-18 Thread sounak chakraborty
  
dear sir
The number of processes that are being created in
fork.c() in function do_fork are less than the  number
of processes are being terminated in exit.c in
function do_exit().
I am placing a printk() in both the above
functions do_fork() and do_exit() and thus after
compiling and then restarting i am getting exit
messages of many process ids that have not yet been
formed.


Another question is that while we are using an AND
operation to distinguish between a process and a
thread (
if(p->flags & CLONE_VM)
 in fork.c in function do_fork() in linux kernel 2.6.8
).

But if i use the above check in do_exit() , will
it be able to distinguish between a thread and a
process in the same manner as do_fork().
If this is not the case , then plz tell where i am
wrong and rectify my mistake.

One more problem is while p->active_mm is equal to
NULL in case of kernel threads and not NULL in case of
user level threads ; through this check we can
identify kernel and user level threads in fork.c but
in exit.c the same p->active_mm value is not NULL for
kernel and user level threads.
   Hence i want to know how can i make a distinction
between kernel and user threads . Is there any other
way?

 Eagerly waiting for a reply,
 Thanks in advance,
 Sounak



Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


error while implementing kill()

2005-03-23 Thread sounak chakraborty
  
dear sir,
 I am unable to use the system call kill(pid,sig).I
have included the header file . I used it in
a module to kill a process. The module is compiling
properly but giving the following error while
inserting the module,
   unresolved symbol kill()

I am unable to track the bug here. 
kindly help me out.

I want to kill a process through the process ID inside
a module.
Is there any other approach other than using the
kill() function?

Thanks in advance,

sounak


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


timer implementation

2005-03-23 Thread sounak chakraborty
  
dear sir
  i want to implement a timer inside the kernel 
so that a specific function of mine is called after
certain period of time

how to implement that?

thanks in advance
sounak


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


repeat a function after fixed time period

2005-03-23 Thread sounak chakraborty
dear sir 
i want to call my own function inside the kernel 
after a fixed interval(i.e some kind of timer)
how to do that which function i have to use to 
repeat the function


anather way is that making my own system call 
which calls my function and 
this sytem call is being access by a user program
which calls it after a fixed inter val of time
 will this be correct
thanks 
sounak


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


compilation problem of modules

2005-03-02 Thread sounak chakraborty

the code of the module that i written is as follows:
#define MODULE
#include 
#include 
#define MODULE_NAME "manti"
struct manti
{
  char mm[20];
 };
static struct proc_dir_entry *example_dir;
struct manti m1;
int init_module(void)
{
  example_dir=proc_mkdir(MODULE_NAME,NULL);
 if(example_dir==NULL)
  {
 printk("<1> error in creation of proc file\n");
}
  else
   printk("<1>success in creation of proc dir\n");
  }
void cleanup_module(void)
{
   remove_proc_entry(MODULE_NAME,NULL);
  printk("<1>proc entry removed\n");
 }

here iam just making one directory in the proc file
named manti
i am trying to  compile it like
gcc -c proc.c 
where the kernel version is 2.4.20-8

but i am getting following errors 

In file included from proc.c:5:
/usr/include/linux/proc_fs.h:47: parse error before
"off_t"
/usr/include/linux/proc_fs.h:51: parse error before
"off_t"
/usr/include/linux/proc_fs.h:57: parse error before
"mode_t"
/usr/include/linux/proc_fs.h:59: parse error before
"uid"
/usr/include/linux/proc_fs.h:60: parse error before
"gid"
/usr/include/linux/proc_fs.h:70: parse error before
"count"
/usr/include/linux/proc_fs.h:72: parse error before
"rdev"
/usr/include/linux/proc_fs.h:176: parse error before
"mode_t"
/usr/include/linux/proc_fs.h: In function
`proc_net_create':
/usr/include/linux/proc_fs.h:177: `NULL' undeclared
(first use in this function)
/usr/include/linux/proc_fs.h:177: (Each undeclared
identifier is reported only once
/usr/include/linux/proc_fs.h:177: for each function it
appears in.)
/usr/include/linux/proc_fs.h: At top level:
/usr/include/linux/proc_fs.h:181: parse error before
"mode_t"
/usr/include/linux/proc_fs.h: In function
`create_proc_entry':
/usr/include/linux/proc_fs.h:181: `NULL' undeclared
(first use in this function)
/usr/include/linux/proc_fs.h: In function
`proc_symlink':
/usr/include/linux/proc_fs.h:185: `NULL' undeclared
(first use in this function)
/usr/include/linux/proc_fs.h: At top level:
/usr/include/linux/proc_fs.h:186: parse error before
"mode_t"
/usr/include/linux/proc_fs.h: In function
`proc_mknod':
/usr/include/linux/proc_fs.h:187: `NULL' undeclared
(first use in this function)
/usr/include/linux/proc_fs.h: In function
`proc_mkdir':
/usr/include/linux/proc_fs.h:189: `NULL' undeclared
(first use in this function)
/usr/include/linux/proc_fs.h: At top level:
/usr/include/linux/proc_fs.h:192: parse error before
"mode_t"
/usr/include/linux/proc_fs.h:193: parse error before
"off_t"
/usr/include/linux/proc_fs.h:193:
`create_proc_read_entry' declared as function
returning a function
/usr/include/linux/proc_fs.h:196: parse error before
"mode_t"
/usr/include/linux/proc_fs.h: In function
`create_proc_info_entry':
/usr/include/linux/proc_fs.h:197: `NULL' undeclared
(first use in this function)
/usr/include/linux/proc_fs.h: At top level:
/usr/include/linux/proc_fs.h:203: `NULL' used prior to
declaration
proc.c: In function `init_module':
proc.c:16: `NULL' has an incomplete type
proc.c:17: invalid operands to binary ==
proc.c: In function `cleanup_module':
proc.c:26: `NULL' has an incomplete type



how to solve it 
plz help me
is my compilation method is wrong or something else 

thanks 
sounak


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


architecture to implement communication between static kernel with dynamic module

2005-03-03 Thread sounak chakraborty
there is one my_own module
which i will insert whenever i like through 
insmod.
thus when the module is loaded it will create a proc
file 

now i want to send the structure variable of
task_struct
i.e p to the module from the kernel at point when the
execution passes
through forking a new process i.e 
at the function do_fork() in fork.c in linux/kernel
folder

how to do this

how can i call the module from that point  (i.e in
do_fork())
and pass the task_struct *p as parameter to the module

can i declare an arbitary name in fork.c of my module
and compile the new kernel?
i think i cannot since i am inserting a dynamic module
to a static kernel executable
and how does the kernel will know that this module
will be attached later to it.
it will show errors while compiling the new modified
kernel

can you help me ?
what path i must take
thanks 
sounak 




Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


symlink to proc file

2005-03-06 Thread sounak chakraborty
  dear sir 
i want to create a symbolic link to my own proc file
system (which has been already created in
/fs/proc/root.c)  from the /kernel/fork.c
how to do it 
i actually want to write inside the proc directory
using the syslink 
what will be the syntax and the parameter passed
could you plz explain me the parameters passed 
to 

struct proc_dir_entry* proc_symlink(const char* name,
struct
proc_dir_entry* parent, const char* dest);

thanks 
sounak


Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Boot sequence of /proc filesystem

2005-03-08 Thread sounak chakraborty
Hi,
   I am writing some piece of code in  the
linux kernel 2.6.8 , in the files
linux-2.6.8/kernel/fork.c ( in function do_fork() )
and linux-2.6.8/kernel/exit.c ( in the function
do_exit() ).

   My objective is to execute the code immediately
after the kernel has mounted the /proc filesystem.
This is because i am creating new subdirectories in
the /proc fs.

  What is the checking condition i should place
inside the kernel so that i can verify that the /proc
fs has been mounted during booting and now my code can
be executed by the kernel.

  Is there any global variable that gets turned on
when the /proc fs is mounted during booting.
  
  Also my code should continue executing until the
/proc fs has been unmounted during shutdown process.

  It would really help me if you can suggest a
wayout.
 
Thanks in advance.
Sounak


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


mounting and unmounting of /proc filesystem

2005-03-09 Thread sounak chakraborty
hi
   which file and function inside the kernel (is
called) during the mounting of proc file system while
system startup.
 Is it do_mount?
  
   And in which function does the unmounting of the
proc file system
during shutdown
thanks 
sounak


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: repeat a function after fixed time period

2005-03-23 Thread sounak chakraborty

--- linux-os <[EMAIL PROTECTED]> wrote:
> On Wed, 23 Mar 2005, Arjan van de Ven wrote:
> 
> > On Wed, 2005-03-23 at 15:56 -0500, linux-os wrote:
>  static void start_timer(void)
>  {
>   if(!atomic_read(&info->running))
>   {
>   atomic_inc(&info->running);
> >>>
> >>> same race.
> >>
> >> No such race at all.
> >
> > here there is one; you use add_timer() which isn't
> allowed on running
> > timers, only mod_timer() is. So yes there is a
> race.
> >
> 
> Well add_timer() is only executed after the timer
> has expired
> or hasn't started yet so the "isn't allowed" is
> pretty broad.
> If I should use mod_timer(), then there are a _lot_
> of buggy
> drivers in the kernel because that's how a lot
> repeat the
> sequence. Will mod_timer() actually restart the
> timer???
> 
> If so, I'll change it and thank you for the help.


   i have applied the code
as i was intedded to call a function repeated ly in
fork.c i written the code over there 
it compiled smoothly 
but while booting 
it is showing
kernel panic no init found
kjournal starting .commit interval after 5 seconds

sounak


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


sched.c function

2005-03-23 Thread sounak chakraborty

Dear sir,

 I am new to kernel. I want to know which function in
the file sched.c or procedure is called to bring a
process for processing in the CPU after context
switching. 

Thanks in advance,
Sounak


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: sched.c function

2005-03-24 Thread sounak chakraborty


> What exactly do you want to know about the
> scheduler?
> 
I had a wild idea  to process one function that
repeatedly checks the task list and find out which
process is in which state 

At first i retrieve the information from fork.c in
do_fork() and exit.x in do_exit()
but the problem it showed me is that the information
of the task at the beginnig and at the
end(termination)

but the process may be in different states at
different moment in between these two extremes(start
-- end)

So how to know that .

I can  run for_each process after certain interval of
time , but rather than using timer i thought to set a
value or call the function (for_each_process) whenever
sheduling occurs(that is some process is going to
sleep and some are awakening) that is i am getting
some changes in the task list after that..

is my approch is correct ?
or should i implement timer ?
plz help me 

i am sorry if some of my concepts are wrong as i am
new to kernel and would be obliged if you correct me
thank for your help 
sounak  


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: sched.c function

2005-03-24 Thread sounak chakraborty


> Tasks do not change their state without holding a
> lock. (There is an exception,
> but it is justified.)
list after that..
> 
> So you want to record task state changes? That is
> better done at the right
> places in the kernel rather than traversing the task
> list repeatedly (the
> latter is not that performant).

So you want to say that only one task could be running
at a single time 

but how to know which one 
is there any way without traversing the task list
previously i thought of for_each_process(p)
if(p->state==running)

but without this how to find which process is
currently running and other are sleeping 
may it is through "current"

since the current->pid is only running
but i have to run this repeatedly to get the
information of currently running process(since this
may be for a fraction of a second and i can miss that
process if my loop is longer) 
how to do that 
fast timer 
or any other way 
i am little bit confused


> I would be interested in the background: what do you
> need to know the task
> states for?


i want to develop a task manager for threads.
the application reads properly the process information
and the thread information but not able to refresh the
thread information as i am building my own proc file
where only threads are there 
i am distinguishing between process and thread at
fork.c
with clone_vm set..

therefore i need to know which thread is currently
running or not 


there is another problem i am discusing with you 

i want to distinguish between thread and process and
after distinguishing between user thread and kernel
thread 
but i am unable to find any condition which will be
true for kernel level thread during creation and false
for user level thread 
can you help me in this also
thanks 
sounak


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


functions where threads gets exited

2005-01-17 Thread sounak chakraborty
dear sir
i i want to know the information about any the threads
(user and kernal both) that are being exited 
so which file/function is last called for exiting the
threads.
is is do_exit in exit.c or any other fuction 
i need the information about both the user level as
well as kernal level threads
thanks in advance 
sounak


Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


function called when a thread gets terminated

2005-01-17 Thread sounak chakraborty
  dear sir 
i want to design a system moniter for linux 
could you just guide me on what will be the basic
architerture like:
i have thought of
kernel(using printk)->logfile(myfile)->application
but in order to make it real time .please correct me
on this architecture 
and i am unable to find some functions where the user
as well as kernel threads are actually exited also i
want to distinguish between the user level and kernel
level at that moment.but as i have done during the
forking of thread in fork.c in do_fork function
through the use of
if(p->mm==null)i could check the kernel thread or user
thread but i am unable do so during exit in exit.c in
do_exit function it seems that in somewhere between
execution the tsk->mm is being filled up .
so do i need to find some other place from which i can
find out about exiting threads and processes and what
will i check to see the user thread is exited or
kernel thread.
thanks sounak



Yahoo! India Matrimony: Find your partner online. 
http://yahoo.shaadi.com/india-matrimony/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/