linux-kernel,operating-system,kernel , difference between one CPU and multiple CPU in schedule routine - Linux kernel

difference between one CPU and multiple CPU in schedule routine - Linux kernel


Tag: linux-kernel,operating-system,kernel

In Linux kernel (2.6) is there a difference between the performance of the "schedule()" routine in a system that has only one processor than in a system with multiple processors?

I have tried to find the answer in the book "Understanding the Linux kernel (3rd ed.)" but no luck finding the answer.


Difficult to answer this.

One simplistic answer is "yes, of course, there is a difference in performance between one cpu and multiple cpus since, when there are multiple CPUs, the kernel must lock various data structures thereby potentially encountering contention, and must decide which CPU a task can next run on, and so forth -- decisions that need not be made (or can be made trivially) when there is only a single CPU."

Another simplistic answer is, "no, the performance impact of the various decisions is minimal and represents a negligible percentage of the total combined CPU 'bandwidth'".

The full answer requires knowledge and consideration of the thousands of factors that go into the scheduling decision on all the available CPUs in any given scenario: Is there an explicit affinity mask set for each process? What interrupts and soft interrupts are being serviced by each CPU? Are the processes being scheduled on each CPU I/O-bound or CPU-bound? Are there processes communicating with other processes where both can run simultaneously on different processors? So many factors, it's impossible to enumerate all the possibilities.


Memory Management (Allocating Pages/Frames to Logical Addresses)

I am new to Operating Systems and I was following this handbook which I am reading to get a better grasp on how computers really work. However having stumbled upon Memory Management I found it somewhat confusing when allocating Frames to Pages using Page tables. Say Page/Frame size is 4K...

What fpu_xrstor_checking does? extra commentary?

I am doing my own version of do_fork() (for many purposes). So, basically, I am copying the process from one place to another, possibly to another machine. Copying the code and pasting it here would be tough. But this explanation should good enough, I believe. My code works most of...

Why my process has been killed?

I have a program, written on C/C++ by myself, that is killed by Linux. The message "killed" appears. Willing to dig out the problem I observed inside the file /var/log/kern.log: Out of memory: Kill process 3915 (my_proj) score 236 or sacrifice child Killed process 3915 (my_proj) total-vm:5503376kB, anon-rss:3857420kB, file-rss:40kB I...

Coding of Admin-Guest login section in an OS

I developed an authentication algorithm for user authentication as part of my masters thesis and implemented it in PHP. I intend to know how can I implement the algorithm for operating system login, in which language (for linux)? also where the code will reside because it will not be click...

OS- How to properly print a spacebar in the video memory in a kernel?

I know this the title is weird (I don't know how to explain it :| )but if u see my problem u will get it. I am making an os in assembly and c i have made a kernel and i have text input and output but i am having...

Difference between switch & bus architecture?

I was just going through a operating systems textbook but I got stuck at switch architecture . Please explain what it is and how it is different from bus architecture ?...

Add module to angstrom kernel

I'm working on the Altera cyclone V Soc FPGA Dev Kit. I'm using the GSRD 14.1 Angstrom provides by ( [email protected]_cyclone5:~# uname -a Linux socfpga_cyclone5 3.10.31-ltsi This kernel don't support usb serial device and I think that I need to add usbserial and maybe usbcore drivers to communicate with...

unknown field 'ioctl' specified in initializer

I implement a simple example to study the usage of ioctl interface according to the book LDD3. When I compiling the codes, unknown field 'ioctl' specified in initializer. is reported. I guess the difference of kernel version between LDD3's and mine causes this error. I'm now using Debian 8 with...

How to divide the L2 cache between the cores on a ARM Cortex-A7?

Context and goal I'd like to run two fully standalone applications on my Olimex A20 Lime platform that run a ARM Cortex-A7. The goal is to dedicate one core to each application. So far so good. Now I'd like to divide the L2 cache between the cores in the following...

Bind multiple threads to multiple CPU?

I have multiple threads that are accessing the same data and it is too painful to make them thread safe. Therefore, they are now forced to run only on one CPU core using CPU affinity and only one thread can be running at the same time. I was wondering if...

Infinite loop when I read from /proc which is implemented with seq_file

I wrote a simple code snippet to learn the usage of /proc file system. When I finished, everything is ok except the reading from this file causes an infinite loop. Some codes show below: static struct seq_operations proc_seq_ops = { .start = proc_seq_start, .next = proc_seq_next, .stop = proc_seq_stop, .show...

^M behind operating system version?

I am currently writing a perl script to extract data from a log file and create statements using the data in a new file. In this new file, one particular data that I've extracted and used here is the operating system's version. It shows Windows XP Service Pack 3^M. I...

Missing headers for kernel in bzImage loaded on qemu

I am trying to compile a kernel module of kernel version 3.2.0 on a linux kernel bzImage loaded on a qemu emulator, however I am getting the following error: /lib/modules/3.2.0/build no such file or directory. I tried to look up solutions over the net but nothing specific related to solve...

Why Device Tree Structure (DTS) file is needed both in bootloader and kernel source code?

Bootloaders like U-Boot that do not implement the Open Firmware API, are expected to pass to the kernel a binary form of the flattened device tree - LinuxFDTBlob Why are the DTS files present in the kernel as well? Isn't that redundant? As an example, U-boot source code has...

Measure memory usage of a certain Linux driver module

I want to check whether the kernel driver module which I just finished has a memory leak problem. But I don't know how to do it in kernel space. Dynamic memory allocation is very hard to handle I think. Anyone has the experience in debugging such memory problem in kernel...

how to get a clock from a device tree node

I have the following issue: I want to define the clock a CPU should use during frequency transitions in the device tree rather than in the clock driver code (in this way it will be more generic). I want to define the "transition-clock" property in the device tree, something like:...

How to tell the difference between linux and mac

I am creating a setup file for a tarball, and I need a way to determine the exact name of the system. I tried, but it returns 'posix' regardless of whether the system is mac or linux. Is there a way to get a more specific OS name?...

NSUserDefaults not working on Xcode beta with Watch OS2

I just installed the latest beta of Xcode to try Swift 2 and the improvements made to the Apple Watch development section. I'm actually having an hard time figuring out WHY this basic NSUserDefaults method to share informations between iOS and Watch OS2 isn't working. I followed this step-by-step tutorial...

How to share same header files between kernel modules and userspace applications.

I want to implement a simple module in which an ioctl() method is used. In the kernel module, I use kernel macros, such as _IO(), _IOWR(), etc., to define my own ioctl sub-commands. In facts, I don't care the actual values of these definitions for that I will always use...

Dynamically find the address at which the kernel is loaded

I'd like to be able to programmatically find out the address at which the linux kernel is loaded. If there are tools out there that already do that, I'd be willing to use them. However, inspecting the PARAMS_PHYS field in the .config during the kernel build is not an option....

Buildroot custom kernel under 1MB

I am trying to build minimal kernel under 1 Mb with Buildroot. It is intended for small board with qspi memory and basic functionality, ethernet, usb, spi, and some GPIO's. Basic terminal access via ssh and UART. My first thoughts are if it is even possible to modify kernel .config...

What does it indicate if /proc/PID/maps shows zero for all addresses?

I'm debugging a problem with a Linux DNS server. Curiously, when I look at /proc/PID/maps for the DNS server process, this is what I get: 00000000-00000000 r-xp 00000000 00:0e 2344 /usr/sbin/unbound 00000000-00000000 rw-p 00000000 00:0e 2344 /usr/sbin/unbound 00000000-00000000 ---p 00000000 00:00 0 00000000-00000000 rw-p 00000000 00:00 0 [heap] 00000000-00000000 rw-p...

Compiling linux module

I've got homework in Operating Systems course, in which I have to write some module. We use Red Hat 8.0 with customed linux kernel I have a makefile for compiling the module, but I fail getting it to work. the module source code is in snake.c and the makefile...

How does the kernel separate threads from processes

Suppose I have a browser process like Firefox, that has pid = 123. Firefox has 5 opened tabs each running in a separate thread, so in total it has 5 threads. So I want to know in depth, how the kernel will separate the process into the thread to execute...

OpenWRT make is failing because kernel is asking for config options interactively

I am on the chaos calmer repo and I have a custom kernel configuration that I need used. The kernel configuration file is located at /opt/OpenWRT/target/linux/x86/config-3.18 I've tried running make kernel_oldconfig, but that does not solve the issue. I've tried running make kernel_menuconfig and that fails to rectify the problem...

Automate MySQL backup @localhost with mysqldump in Windows 8

I'm trying to set up a task in Windows 8 to automate my localhost db dump. I've created the task to run daily with the following command line: C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqldump.exe and parameters: --user=root --password=donttellya --result-file=dumped.sql mydb It works but doesn't terminate (running in the tasks list). Also, I'd...

How do I know the last sched time of a process

I current run into an issue that a process seems stuck somehow, it just doesn't gets scheduled, the status is always 'S'. I have monitored sched_switch_task trace by debugfs for a while, didn't see the process get scheduled. So I would like to know when is that last time scheduled...

I want to sleep while holding a mutex

I need to write to and read from a Ethernet chip's FIFO and for that I want to use DMA controller. So I modified an existing driver and made the process to sleep using wait_event_interruptible after triggering DMA transfer and made it woken up by ISR using wake_up_interruptible. My problem...

Android - What is the difference between a foreground and background service?

From it says that a foreground service is something that the user is aware of and a foreground service is unlikely to be killed if memory is needed. It says a background service may be killed if memory is needed. Is this the only difference or can one service...

Not Used Recently (NUR) Page Replacement Algorithm [closed]

How to implement NUR (Not used recently page replacement algorithm) using any high level programming language (c, c++ or java)

Passing IPC(Instructions/Cycles) continuously to other function or variable

I am trying to read the performance counters and get the IPC. I need to use IPC to control few machine specific parameters. I am using shell script to do the same. Please see the code below: while true do retval=./perf periodic -e instructions -e cycles -s 50 -d -m...

Trouble outputing file size to a label from a listbox in Python 3

I'm using os.path.getsize() to output the size of a file to a label. The file path is stored in a listbox. The function works, but it outputs the file size in bits, so I wrote the following to convert to more appropriate units, and it is now displaying only in...

Calling complete() on automatic variable of type struct completion defined in “waiting” thread

I try to understand use of completion in a piece of code. Basically, one kernel thread creates automatic variable struct completion which is, I assume, allocated on the thread's stack. Then it pushes pointer of the completion struct to another thread (using fifo) and waits for completion. struct completion done;...

CPU new features enabled in Linux kernel

If the CPU has some new features, how does the Linux kernel handle this ? From what I remembered, PAE does not need to rebuild the entire the system and Linux seems like just installing the driver and things work. Say, if the CPU provides more execution modes, Do we...

Why does main function differ from other function from stack point of view

I'm studying to use gdb and i got little confused. Here is my code: #include <stdio.h> #include <stdlib.h> #include <string.h> void g(char *password) { } int main(int argc, char *argv[]) { if(argc > 1) { g(argv[1]); } } So with the regular function (g() in this example) if I want...

Intercept ELF loader in linux kernel: fs/binfmt_elf.c file via loadable kernel module

I am new to kernel coding and at present I am working with ELF files which have been modified a little bit for the security purposes for which I need to look at some of it's custom section headers and extract the unique code encryption key from it for the...

How to build Linux kernel to support SO_ATTACH_BPF socket option?

I want to build a application which supports eBPF on CentOS 7 (the kernel version is 3.10.0): if(setsockopt(sock, SOL_SOCKET, SO_ATTACH_BPF, prog_fd, sizeof(prog_f)) { ...... } So I download a 4.0.5 version, make the following configurations on: CONFIG_BPF=y CONFIG_BPF_SYSCALL=y Then follow this link to build and install a 4.0.5 kernel. After...

Why do we need to install a C++ compiler? [closed]

I have heard that all the popular OSes (Windows, Linux, Mac OS X) are built from C++ or C. Why, then, do we need to install GCC or any C++ compiler? Shouldn't programs be compiled by the computer itself as these operating systems support C++ and C?

ret_from_syscall source code and when it is called

In the below call trace we see function called ret_from_syscall. Which function is this ? When it will called during system call ? Where is the corresponding code for this ? May 7 16:40:34.322086 warn TCU-0 kernel: [cf83ddc0] [00009751] 0x9751 (unreliable) May 7 16:40:34.322086 warn TCU-0 kernel: [cf83ddd0] [c00469ac] do_syslog+0x198/0x424...

How to detect that music play in background

I want help in detecting if there is a music play in background on the phone or not because I play more than one music sequentially in my app but they are intersection thank you

shuting down an OS without using API's

i was trying to add a shutdown feature to my home-made OS , but i don't really have such API yet . i was wondering how does the OS's terminates the power ? i'd be appreciate it if somebody could give me some guidelines for start .

How my computer knows a char corresponds to which character?

Does my OS load a font file which maps the UTF-8 codes to characters(the way to render it ) when I start up my computer? Since there are a lot of different fonts, the font files will consume a lot of memory? Or the font files are stored in hard-disk...

How to change ubuntu to root?

I am new to linux. when i list the files under folder 1, i see below result -rwxrwxrwx 1 root root 920 Jun 3 10:36 file1.xsd -rwxrwxrwx 1 root root 920 Jun 3 10:36 file2.xsd drwxrwxrwx 2 ubuntu ubuntu 4096 Jun 12 11:10 temp -rwxrwxrwx 1 ubuntu ubuntu 1853 Jun...

schedule automate shell script running not as ROOT

I have a shell script that I want to run automatically every day at 08 AM, and I am not authorised to use the crontab because I don't have root permission My home directory is /home/user1/. Any suggestions?...

Sofware pwm as linux kernel module

I need to implement PWM-module for linux kernel, it should be high resolution ( will be cool more than 10kHz on my 400MHz ARM cpu) Can anyone give me an advice, what I can use for that purpose? Kernel version is Device hasn't a harware PWM driver. Now I...

How the kernel functions work?

Normally during a function call the function gets pushed into the stack part of the process and the calling function waits. But the program stack requires a process right? But the kernel is not part of any process (by kernel I mean the part that does file management and interprocess...

When to Update ALSA Audio Driver Buffer Pointer

I am writing an USB Audio Playback driver using ALSA APIs. For that I was trying to understand existing audio drivers in Linux kernel. But I get confused on when to update the kernel audio buffer pointer. We know kernel puts new audio data in a ring buffer and our...

Not checking file size correctly

I wrote a simple script to move movies in my downloads directory, once they are finished downloading, to the location they need to go and have a simple question regarding it. Maybe I'm not understanding how the os module is working to the current size of the file here, but...

How to offload NAPI poll function to workqueue

I'm working with linux 3.3, Ethernet driver for smsc911x. and I want to move the NAPI poll function to workqueue. My questions are : 1. How do I pass the NAPI poll function arguments to the work_struct? 2. How do I get the NAPI poll function arguments back from the...