Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Print some information of all the processes pointed by init_task, something similiar to "ps -ef", including UID, PID, PPID, thread name, etc.
Create five kernel threads using the following methods:
Create 2 threads using kernel_thread()
Create 3 threads using kthread_create()
Print some information of all the processes including the five threads. The output will be part of dmesg or messages. Try to follow the "ps -ef" format when printing all the processes including your own threads.
See the sample output below that shows the process list and the boot time messages.

Example: process list ("$ps -ef")
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 09:36 ? 00:00:00 /sbin/init
root 2 0 0 09:36 ? 00:00:00 [kthreadd]
root 3 2 0 09:36 ? 00:00:00 [ksoftirqd/0]
root 4 2 0 09:36 ? 00:00:00 [migration/0]
root 5 2 0 09:36 ? 00:00:00 [watchdog/0]
root 6 2 0 09:36 ? 00:00:00 [events/0]
root 7 2 0 09:36 ? 00:00:00 [khelper]
root 10 2 0 09:36 ? 00:00:00 [kstop/0]
root 145 2 0 09:36 ? 00:00:00 [kintegrityd/0]
root 147 2 0 09:36 ? 00:00:00 [kblockd/0]
...
root 579 2 0 09:36 ? 00:00:00 [hid_compat]
root 612 1 0 09:36 ? 00:00:00 [My name:my_d]
root 613 1 0 09:36 ? 00:00:00 [My name:my_d]
root 614 2 0 09:36 ? 00:00:00 [my_kernel_threa]
root 615 2 0 09:36 ? 00:00:00 [my_kernel_threa]
root 616 2 0 09:36 ? 00:00:00 [my_kernel_threa]
root 632 2 0 09:37 ? 00:00:00 [kjournald]
root 681 1 0 09:37 ? 00:00:00 /sbin/udevd -d
...

For creating the first 2 threads try the following procedure:

Declare the functions that will create threads and those threads that will actually do something:
static void my_kernel_thread_create_1(void);
static void my_kernel_thread_create_2(void);

...

static void my_kernel_thread_create_1(void){
int mypid;
printk(KERN_NOTICE "My name: Calling kernel_thread(m_k_t_do_something_1)n");
mypid = kernel_thread(m_k_t_do_something_1, NULL, CLONE_KERNEL);
printk(KERN_NOTICE "My name: m_k_t_do_something_1 = %dn", mypid);
}

static void my_kernel_thread_create_2(void){
int mypid;
printk(KERN_NOTICE "My name: Calling kernel_thread(m_k_t_do_something_2)n");
mypid = kernel_thread(m_k_t_do_something_2, NULL, CLONE_KERNEL);
printk(KERN_NOTICE "My name: m_k_t_do_something_2 = %dn", mypid);
}

...

static void m_k_t_do_something_1(void){
struct task_struct *curtask = current;
strcpy(curtask->comm, "My name: m_k_t_do_something_1");
set_task_state(curtask, TASK_RUNNING);
printk(KERN_NOTICE "My name: m_k_t_do_something_1 is about to be scheduled.n");
schedule();
printk(KERN_NOTICE "My name: m_k_t_do_something_1 is now scheduled.n");
}

static void m_k_t_do_something_2(void){
struct task_struct *curtask = current;
strcpy(curtask->comm, "My name: m_k_t_do_something_2");
set_task_state(curtask, TASK_RUNNING);
printk(KERN_NOTICE "My name: m_k_t_do_something_2 is about to be scheduled.n");
schedule();
printk(KERN_NOTICE "My name: m_k_t_do_something_2 is now scheduled.n");
}
...
Call those functions that will create these threads.
...
print some info on all the processes on runqueue;
...
printk(KERN_NOTICE "My name: m_k_t_do_something threads are about to be created.n");
my_kernel_thread_create_1();
my_kernel_thread_create_2();
...
printk(KERN_NOTICE "My name: m_k_t_do_something threads are created.n");
...
print some info on all the processes on runqueue;
...
run_init_process("/sbin/init");
...
Remember to print process info before you call these functions, after you calll the functions, and after terminate
For creating the last 3 threads try the following procedure:

Declare the functions that create threads and those threads that actually do something like the above.
Use kthread_create() to create kernel threads. kthread_create() adds the newly created kernel thread to the global list kthread_create_list, as we discussed in class.
See apm_init() as an example.
static int __init apm_init(void){
...
kapmd_task = kthread_create(apm, NULL, "kapmd");
...
}

For printing some info on processes, try the following:

...
struct task_struct *tmp_tsk;
...
tmp_tsk = current;
for_each_process(tmp_tsk) {
...
print some info on all the processes on runqueue;
...
}
Now, remove all the threads you created and print all the processes, something similiar to "ps -ef".

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91055330

Have any Question?


Related Questions in Computer Engineering

Albert hoffmans wife has an ipod shuffle with five songs in

Albert Hoffman's wife has an iPod shuffle with five songs in her library: November Rain  by Guns 'N Roses Ain't No Mountain High Enough  by Nicholas Ashford and Valerie Simpson Call Me Maybe  by Carly Rae Jepsen Rainbow ...

Write review on this article with apa formatdigital

Write review on this article with APA format. Digital evidence has become a key component of the judicial process, due solely to the frequency of communications and transactions completed on computers and mobile devices. ...

Question write a 1-2 page paper in apa format describe how

Question: Write a 1-2 page paper in APA format. Describe how Windows Active Directory enhances security in your organization. What, if anything, could be improved? This project is due On Saturday morning 9/22. The respon ...

Suppose a record has the following fields in this order a

Suppose a record has the following fields in this order: A character string of length 15, an integer of 2 bytes, a SQL date, and a SQL time (no decimal point). How many bytes does the record take if: Fields can start at ...

Section 26 in the smith textbook elementary information

Section 2.6 in the Smith textbook ( elementary information security 2nd edition) offers a list of 6 high-level security controls. Pick two of them and describe how you personally experience those controls in use on perso ...

Submit your solution as a plain-text file with a c

Submit your solution as a plain-text file with a .c extension in the name. Name timer - counts down to zero from a user supplied number. Description Displays a count down to zero from a number supplied by the user at the ...

Using jython 50 or higherwrite a 2-part program as

Using Jython 5.0 or Higher: Write a 2-part program as follows: Part 1: Write a function to convert Celsius to Fahrenheit Part 2: Write a function to convert Farenheit to Celsius Both of the functions (Celsius to Farenhei ...

Why are standards needed in data communication and

Why are standards needed in data communication and networking? What are the advantages and disadvantages of standards? How do standards fit in with regulations at the federal, manufacturing, and organizational levels? Gi ...

Ellen is an anthropologist who has been working at olduvai

Ellen is an anthropologist who has been working at Olduvai Gorge in Tanzania for the past six months. She has been conducting research on the Internet. She finds a Web site with an article that proposes a revolutionary t ...

What are some of the uses of bayes theorem as in what type

What are some of the uses of bayes' theorem. As in what type of problems could I come across in a Biostatistics quiz

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As