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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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