LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 09-01-2018, 10:49 AM   #1
nissik
LQ Newbie
 
Registered: Sep 2018
Posts: 1

Rep: Reputation: Disabled
Implementing efficient usermode scheduling


I am interested in an efficient implementation of usermode scheduling using threads. When just doing stack switching, it doesn't work so well with thread-local storage, and since you don't swap thread information, things like nice don't work either. Debugging stack-switching code also sucks.
I am confident this can be done efficiently (roughly 200ns per switch) with specialized system calls as is claimed in this video:
https://www.youtube.com/watch?v=KXuZi9aeGTw

However the person who presented that apparently hasn't shared the source code for that, so I've been trying to implement it myself. I am a noob though so I am not quite sure how to get this thing right. So far I have this basic working code, but it is nowhere near as efficient as it could be. It takes roughly 10us per switch according to a microbenchmark I did, although that is on multicore. Disabling all cores but #0 speeds it up to to 1.6us per switch. As I understand, the optimization that is possible to make is that you can simply replace current the node in the runqueue instead of removing the current and inserting the next. I don't know what that would look like and what you'd have to take into consideration to implement it.
So, how to improve this?
Code:
SYSCALL_DEFINE2(ums, int, mode, pid_t, pid)
{
	switch (mode) {
	case 0: /* suspend current */
		set_current_state(TASK_INTERRUPTIBLE);
		schedule();
		return 0;
	case 1: /* suspend current, run @pid */
		next = find_task_by_vpid(pid);
		if (!next)
			return -EINVAL;

		set_current_state(TASK_INTERRUPTIBLE);
		while (!wake_up_process(next));
		schedule();
		return 0;
	default:
		return -EINVAL;
	}
}
 
Old 09-08-2018, 10:57 AM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
This pretty much explains it: https://pdfs.semanticscholar.org/pre...aa6eda5bdd.pdf
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Implementing EEDCP (energy efficient dynamic clustering protocol) in Ns-2 nik.dan Linux - Software 0 10-24-2013 12:44 AM
UserMode Question - I/O Without Polling? Peatmoss Programming 6 12-19-2007 06:47 AM
usermode linux booting problem tgo Linux - Software 1 12-19-2006 08:40 PM
usermode linux problem tanalam Linux - Newbie 1 11-29-2006 08:00 AM
usermode linux (UML) rc5 Arch 0 03-15-2004 01:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration