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

  Write the complete myfnc function to return the value 1

Write the complete myfnc function to return the value 1 if they are equal and return the value 0 if they are not equal.

  Public peering and private peering in net neutrality

What is the difference between "public peering" and "private peering"?

  Create a pseudocode that reads in temperature input

Create a pseudocode that reads in temperature input. It should print "Freezing cold!" if the temperature is 32 degrees or below.

  Discuss whether you accept demand from manager

Discuss whether you should accept this demand from your manager or whether you should persuade your team to give their time to the organization rather than to their families. What factors might be significant in your decision?

  Information and communications technology

Assume that you have been contracted to address the current (2014) ICT Infrastructure requirements of this university within the context of the two questions asked above

  Draw an rea diagram-data modeling and database design

Data modeling and database design,  Draw an REA Diagram,  Draw an REA diagram for Sparky’s revenue cycle only. Be sure to include cardinalities. State any assumptions you had to make.

  What staffing we would need for two possible scenarios

What could those be? If we outsource would we need to have someone from the company that monitors them? What skills or knowledge would they need.

  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)

  How many total bits are required for a direct-mapped cache

How many total bits are required for a direct-mapped cache with 16 KB of data and 4-word blocks, assuming a 32-bit address.

  Critique website that is different to rest of our friends

Web devolving assignment - Critique a website that is different to the rest of our friends-classmates.

  Investigate project management body of knowledge

Investigate Project Management Body of Knowledge (PMBoK). Write a report on one of knowledge areas. Describe the task of understanding potential threats

  What is maximum size of a file can be stores in file system

This file system has 12 direct disk blocks, as well as single, double, and triple indirect disk blocks. What is the maximum size of a file that can be stores in this file system?

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