Information of all the processes pointed by init

Assignment Help Basic Computer Science
Reference no: EM13518212

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".

Reference no: EM13518212

Questions Cloud

The network administrator of lenix ventures : The network administrator of Lenix Ventures
Identify the troublesome computer''s ip address and host : What commands would you use to identify the troublesome computer's ip address and host name?
Write a small program in java that builds routing tables : Write a small program in Java that builds routing tables for nodes based on shortest path routing using dijkstras algorithm. Where path distance is measured by edges. The input for this problem is the connectivity information for all the nodes..
Personal trainer : PERSONAL TRAINER, INC.
Information of all the processes pointed by init : Print some information of all the processes pointed by init_task, something similiar to "ps -ef", including UID, PID, PPID, thread name, etc.
Linear programming problem using branch and bound : Solve this linear programming problem using Branch and Bound
Research the key terms : Research the key terms
Describe the state of nuclear energy : Based on current events, describe the state of nuclear energy and its peaceful uses in at least one country.In your opinion, which is the greater threat
What is the basis of kantianism : What is the basis of Kantianism? You have Machiavellianism, Grotianism and Kantianism. What is the primary way in which Kantianism differs from the other two?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  State turing machine m that calculates function

State a Turing Machine M that computes the function f: {a, b}* → N, where: f(x) = the unary encoding of max(#a(x), #b(x)).

  Write program that will calculate square and cube of numbers

Write a program that will calculate square and cube of numbers ranging from 0 to 10. Print the output like the following table (hint: use for loop, to print as a table use printf formatting for width).

  Write a class that maintains the top 10 scores

but use a singly linked list instead of an array Part 2: Implement the stack and queue with a single class interfaces with a unique class that is derived from class LinkedDeque (Code Fragment 5.21)

  Explain hacktivism includes cracking for higher purpose

And "hacktivism" includes cracking for "higher purpose". Is it feasible to crack systems and still be ethical? Support the position.

  Implement the stack and queue with a single class

Implement the stack and queue with a single class interfaces with a unique class that is derived from class LinkedDeque (Code Fragment 5.21)

  Write an anonymous block that places a substitution variable

Write an anonymous block that places a substitution variable (&) into a local variable of type character. You should check the value entered in the local variable and output different messages depending on the value provided.

  What is capacity with two shifts

Given the following data for Albert's fabricating production area:Fixed costs for one shift = $60,000. What is the capacity with two shifts? The additional fixed cost for a second shift is $40,000.

  Information system to use for stocks and trading futures

Write down some of the many considerations in selecting right information system to use for trading futures and stocks?

  Explaining resulting scheme is not ind-cpa-secure

Let a variant of CBC-mode encryption where sender simply increments the IV by 1 each time a message is encrypted. Illustrate that resulting scheme is not IND-CPA-secure.

  Add the following numbers in two''s complements

Given four bits, add the following numbers in two's complements. a. - 4 + (- 1), b. -7 + 3, c. -5 + 4

  Review the code of ethics of the institute of electrical

Review the code of ethics of the Institute of Electrical and Electronics Engineer (IEEE) and National Society of Professional Engineers (NSPE).

  Discuss the points and tabulate the strengths and weaknesses

Discuss the points and tabulate the strengths and weaknesses

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd