1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sloan [31]
3 years ago
7

Design a kernel module that iterates through all task in the system using the for_each_process() macro. In particular, output th

e task name (known as executable name), state, and process id of each task. (You will probably have to read through the task_struct structure in to obtain the names of these fields.) write this code in the module entry point so that its contents will appear in the kernel log buffer, which can be viewed using the dmesg command. To verify that your code is working correctly, compare the contents of the kernel log buffer with the output of the following command, which lists all tasks in the systemps -el
The two values should be very similar. Because tasks are dynamic, however, it is possible that a few tasks may appear in one listing but not the other.

#include

struct task_struct *task;

for_each_process(task) {
/* on each iteration task points to the next task */
}
The various fields in task_struct can then be displayed as the program loops through the for_each_process() macro.
Computers and Technology
1 answer:
aleksley [76]3 years ago
5 0

Answer:

#include <linux/kernel.h>

#include <linux/module.h>

#include <linux/init.h>

#include <linux/sched/signal.h>

#include <linux/sched.h>

 

 

struct task_struct *task;        /*    Structure defined in sched.h for tasks/processes    */

struct task_struct *task_child;        /*    Structure needed to iterate through task children    */

struct list_head *list;            /*    Structure needed to iterate through the list in each task->children struct    */

 

int iterate_init(void)                    /*    Init Module    */

{

   printk(KERN_INFO "%s","LOADING MODULE\n");    /*    good practice to log when loading/removing modules    */

     

   for_each_process( task ){            /*    for_each_process() MACRO for iterating through each task in the os located in linux\sched\signal.h    */

       printk(KERN_INFO "\nPARENT PID: %d PROCESS: %s STATE: %ld",task->pid, task->comm, task->state);/*    log parent id/executable name/state    */

       list_for_each(list, &task->children){                        /*    list_for_each MACRO to iterate through task->children    */

 

           task_child = list_entry( list, struct task_struct, sibling );    /*    using list_entry to declare all vars in task_child struct    */

     

           printk(KERN_INFO "\nCHILD OF %s[%d] PID: %d PROCESS: %s STATE: %ld",task->comm, task->pid, /*    log child of and child pid/name/state    */

               task_child->pid, task_child->comm, task_child->state);

       }

       printk("-----------------------------------------------------");    /*for aesthetics*/

   }    

     

 

   return 0;

 

}                /*    End of Init Module    */

     

void cleanup_exit(void)        /*    Exit Module    */

{

 

 

   printk(KERN_INFO "%s","REMOVING MODULE\n");

 

}                /*    End of Exit Module    */

 

module_init(iterate_init);    /*    Load Module MACRO    */

module_exit(cleanup_exit);    /*    Remove Module MACRO    */

 

MODULE_LICENSE("GPL");

MODULE_DESCRIPTION("ITERAT

You might be interested in
Using the XML Document below (library with books), define the following queries in XQuery: (a) Give the titles of all Books sort
Softa [21]

Answer:

Explanation:

a)use order by clause for sorting

for $x in doc("books.xml")/bib/book order by xs:float($x/price) return $x/title (default sorted in ascending order)

or

for $x in doc("books.xml")/bib/book order by xs:float($b/price) descending  return $b/title (sorted in descending order)

b)doc("books.xml")//book[author = 'Abiteboul']

c)for $x in distinct-values(doc("bib.xml")/bib/book/author)

return <res>

<name>{$x}</name>

<count>

 {count (doc("bib.xml")//book[exists(indexof(author,$x))]) }

</count>

<res>

3 0
3 years ago
when a stock or bond certificate is delivered, it must be in good transferable form. if the certificate is badly mutilated, it m
Elena-2011 [213]

Authentication can be done by the issuer of the security.

What do you mean by authentication?

Authentication is the act of proving an assertion, such as a computer system user's identification. Authentication is the process of verifying a person's or thing's identity, as opposed to identification, which is the act of indicating that identity. It could entail validating personal identification documents, verifying the authenticity of a website with a digital certificate, carbon dating an artefact, or guaranteeing that a product or document is not counterfeit.

Only a party with access to particular company documents may authenticate a mutilated certificate. It is most likely the issuer, but it could also be the transfer agent or registrar.

To learn more about authentication
brainly.com/question/28240257

#SPJ4

6 0
1 year ago
Why does the position of drawCircle(x, y, r) in the answer choices matter?
Andrei [34K]

Answer:

B and C

Explanation:

xPos and yPos determine the center of the circle, and rad determines the radius of the circle drawn.

It cannot be A because it starts drawing a circle with the center of (4, 1). None of the circles ahve a center at (4, 1). It is B because while it does start at (4, 1), the repeat function adds one to the y and radius. While ti repeats 3 times it ends up drawing all 3 circles. C also works because it starts by drawing the biggest circle and then subtracting the values to make the other two. It cannot be D because in the repeat function it subtracts from the y value and radius too early, it doesn't draw the biggest circle.

6 0
2 years ago
Which sign or symbol will you use to lock cells for absolute cell reference?
ivanzaharov [21]
It's asterisk hope this helped
7 0
3 years ago
Read 2 more answers
In a stack data structure, the following items are inserted in the following order: Bob, Alice, Charlie, Eve, Zebra. Then an ite
const2013 [10]

Answer:

Zebra.

Explanation:

Stack is LIFO, so Zebra is added in the last so it will be removed first.

6 0
3 years ago
Other questions:
  • In scratch the location of a sprite is defined by what?
    10·1 answer
  • ​In addition to joint application development, another popular user-oriented method is _____, which resembles a condensed versio
    14·1 answer
  • Round Robin Algorithm
    14·1 answer
  • What happens when the following code segment executes if test.txt does not exist?:<br> A,B,C,D?
    7·1 answer
  • What is are motor vehicle emissions?
    8·1 answer
  • Paul is a chemical engineer working with large storage tanks of chemicals. Working from home using a program on his computer, he
    5·1 answer
  • As a general rule, what is the size of a brochure?
    11·1 answer
  • Each of these is a step in cEach of these is a step in conflict resolution: Evaluate solutions suggested. Define the problem. De
    7·1 answer
  • MyProgramming Lab
    5·1 answer
  • Physical and data link layer standards govern transmission in ________. LANs WANs Both LANs and WANs Neither LANs nor WANs
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!