linux lover

The Way of the great learning involves manifesting virtue, renovating the people, and abiding by the highest good.

2010年5月29日星期六

Minix3 Scheduler

Minix3 Scheduler

有关minix3的调度,相关的理论在  Operating Systems - Design and Implementation, 3rd Edition 中的  Scheduling in Interactive Systems   里介绍,
  • Round-Robin Scheduling
  • Priority Scheduling
  • Multiple Queues
  • Shortest Process Next
  • Guaranteed Scheduling
  • Lottery Scheduling
    之类的算法 。这个和批处理系统的job调度不同,所以不可能实现First-Come First-Served,Shortest Job First ,Shortest Reming Time Next之类的调度算法,下面找了一个国外UCSB大学的操作系统课程的相关Minix操作系统的调度算法,有点意思。


Adding a Lottery Scheduler to Minix

This portion of Project 1 requires you to change the process scheduler functionality inside Minix.  Obviously, you will need to modify Minix kernel code to make this happen.  Specifically, you will be adding functionality to support Lottery Scheduling. Lottery scheduling is a flexible way to schedule CPU time by giving each process a number (n) of tickets.  Each time the scheduler is called, it looks at the total number of tickets outstanding (i.e. held by all processes).  It randomly chooses one of the outstanding tickets, and the process holding that ticket is the process that gets to run.  The intuition is that processes can increase or decrease their share of the CPU by getting or giving away tickets.

Modifying the scheduler for Minix should mostly involve modifying code inkernel/proc.c , specifically thesched() and pick_proc() functions (and perhaps enqueue() and dequeue() ). You may also need to modifykernel/proc.h to add elements to the proc structure and modify queue information (NR_SCHED_QUEUES, TASK_Q, IDLE_Q, etc.) and may need to modify PRIO_MIN  and PRIO_MAX in/usr/include/sys/resource.h. Process priority is set in do_getsetpriority()  inservers/pm/misc.c(don't worry—the code in here is very simple), which calls do_nice()  inkernel/system.c. You might be better off just using the nice()system call , which calls do_nice()directly. You'll probably want to modify what do_nice() does to assign or take away tickets.

The current MINIX scheduler is relatively simple. It maintains 16 queues of "ready" processes, numbered 0-15. Queue 15 is the lowest priority (least likely to run), and contains only the IDLE task. Queue 0 is the highest priority, and contains several kernel tasks that never get a lower priority. Queues 1–14 contain all of the other processes. Processes have a maximum priority (remember, higher priorities are closer to 0), and should never be given a higher priority than their maximum priority.  System processes (queues 0-14) are run using their original algorithm, and queue 15 still contains the idle process. However, queue 16 contains all of the runnable user processes, each of which has some number of tickets. The default number of tickets for a new process is 5. However, processes can add or subtract tickets by calling setpriority(ntickets), which will increase the number of tickets by ntickets (note that a negative argument will take tickets away). A process cannot accumulate more than 100 tickets.

Each time the scheduler is called, it should randomly select a ticket (by number) and run the process holding that ticket. Clearly, the random number must be between 0 and Tickets-1, where Tickets is the sum of all the tickets belonging to processes in the ready queue (processes that are blocked are ineligible to run). You may use the random() call (you may need to use the random number code in/usr/src/lib/other/random.c) to generate random numbers and thesrandom() call to initialize the random number generator. A good initialization function to use would be the current date and time.

New processes are created and initialized in kernel/system/do_fork.c. This is probably the best place to initialize any data structures. 




实现方案:



reference:


Minix3 Scheduler

Minix3 Scheduler

有关minix3的调度,相关的理论在  Operating Systems - Design and Implementation, 3rd Edition 中的  Scheduling in Interactive Systems   里介绍,
  • Round-Robin Scheduling
  • Priority Scheduling
  • Multiple Queues
  • Shortest Process Next
  • Guaranteed Scheduling
  • Lottery Scheduling
    之类的算法 。这个和批处理系统的job调度不同,所以不可能实现First-Come First-Served,Shortest Job First ,Shortest Reming Time Next之类的调度算法,下面找了一个国外UCSB大学的操作系统课程的相关Minix操作系统的调度算法,有点意思。


Adding a Lottery Scheduler to Minix

This portion of Project 1 requires you to change the process scheduler functionality inside Minix.  Obviously, you will need to modify Minix kernel code to make this happen.  Specifically, you will be adding functionality to support Lottery Scheduling. Lottery scheduling is a flexible way to schedule CPU time by giving each process a number (n) of tickets.  Each time the scheduler is called, it looks at the total number of tickets outstanding (i.e. held by all processes).  It randomly chooses one of the outstanding tickets, and the process holding that ticket is the process that gets to run.  The intuition is that processes can increase or decrease their share of the CPU by getting or giving away tickets.

Modifying the scheduler for Minix should mostly involve modifying code inkernel/proc.c , specifically thesched() and pick_proc() functions (and perhaps enqueue() and dequeue() ). You may also need to modifykernel/proc.h to add elements to the proc structure and modify queue information (NR_SCHED_QUEUES, TASK_Q, IDLE_Q, etc.) and may need to modify PRIO_MIN  and PRIO_MAX in/usr/include/sys/resource.h. Process priority is set in do_getsetpriority()  inservers/pm/misc.c(don't worry—the code in here is very simple), which calls do_nice()  inkernel/system.c. You might be better off just using the nice()system call , which calls do_nice()directly. You'll probably want to modify what do_nice() does to assign or take away tickets.

The current MINIX scheduler is relatively simple. It maintains 16 queues of "ready" processes, numbered 0-15. Queue 15 is the lowest priority (least likely to run), and contains only the IDLE task. Queue 0 is the highest priority, and contains several kernel tasks that never get a lower priority. Queues 1–14 contain all of the other processes. Processes have a maximum priority (remember, higher priorities are closer to 0), and should never be given a higher priority than their maximum priority.  System processes (queues 0-14) are run using their original algorithm, and queue 15 still contains the idle process. However, queue 16 contains all of the runnable user processes, each of which has some number of tickets. The default number of tickets for a new process is 5. However, processes can add or subtract tickets by calling setpriority(ntickets), which will increase the number of tickets by ntickets (note that a negative argument will take tickets away). A process cannot accumulate more than 100 tickets.

Each time the scheduler is called, it should randomly select a ticket (by number) and run the process holding that ticket. Clearly, the random number must be between 0 and Tickets-1, where Tickets is the sum of all the tickets belonging to processes in the ready queue (processes that are blocked are ineligible to run). You may use the random() call (you may need to use the random number code in/usr/src/lib/other/random.c) to generate random numbers and thesrandom() call to initialize the random number generator. A good initialization function to use would be the current date and time.

New processes are created and initialized in kernel/system/do_fork.c. This is probably the best place to initialize any data structures. 




实现方案:



reference:


2010年4月1日星期四

GoodReader User Manual

GoodReader User Manual

Use your local WiFi-network to transfer files from your desktop computer to GoodReader.

Please note that WiFi-networking can sometimes be tricky, there are some hidden options that can prevent normal networking. Should you have any difficulties, please consult our Troubleshooting guide or contact our friendly and experienced customer support service.

Preparation steps
(must be performed the first time only, no need to do it every time)
Step 1. Make sure you have your own local WiFi network ready.
 

Step 2. Connect your computer to your WiFi network.
 

Step 3. Connect your iPhone / iPod touch to your WiFi network.
 

hide details

 Start the Settings app on your iPhone / iPod touch:
     
 
Go to Wi-Fi section. Turn the Wi-Fi switch on, if it's off. Find your network (to which your computer is connected, or which is hosted by your computer) in the list, select it, and enter the password for this network, if needed. It isvery important to ensure that you're entering the password correctly, because sometimes, if the password is incorrect, it may look like you're connected to a network, but no actual file transfer will happen. The checkmark should appear against your network name:
     
 
Wait for the WiFi antenna logo to appear at the top of the screen. It may take some time, during which your iPhone registers within the network, so just wait for antenna to appear.
 
Actual Transfer
(must be performed every time)
Step 4. Start GoodReader app on your iPhone / iPod touch.
 

Step 5. Open GoodReader's WiFi-transfer page, keep it open all the time while transferring, note the IP-address on this page (you gonna need it in Step 6).
 

hide details

 For security reasons and to save your battery power transfer is allowed only when you're on the WiFi-transfer page. You can open this page with this button on the main screen of GoodReader:
     
 
This button brings up the WiFi-transfer page:
     
 
The important things here are:
  • antenna logo at the top, it should indicate a strong WiFi signal (if you don't see this logo, then you're not connected to WiFi network - go back to Steps 1 and 3)
  • WiFi status: ON (if it's OFF, then you're not connected to WiFi network - go back to Steps 1 and 3)
  • IP-address (if you don't see it, then you're not connected to WiFi network - go back to Steps 1 and 3)
Note the IP-address, you will use it to initiate a connection from your computer.
 
IMPORTANT: IP-addresses change from time to time, even if nothing else changes in your setup. So please don't assume that the IP-address is the same as it was during your last transfer session, check this address every time when connecting.

Step 6. Choose the transfer method and do the actual transfer.
 

hide details

 
"Easy" transfer
(just a couple of files to transfer)
"Professional" transfer
(many files and folders to transfer)
Transfer by connecting your iPhone/iPod to your computer as a network folder:
 

Step 7. After all the transfer is completely done, close WiFi-transfer page.

Step 6
"Professional" transfer - connecting your iPhone as a network folder

This technique connects your iPhone to your desktop computer as a network folder. It creates a network folder shortcut, which you can use later to connect.

Connecting your iPhone to Windows Vista or Windows 7:

  • on Windows Vista or Windows 7 computer open the Start menu and select Computer:
     
  • find the toolbar at the top of Computer window and click Map network drive:
     
  • the dialog window will open. Do NOT enter anything in that dialog. Instead, click the Connect to a Web site that you can use to store your documents and pictures link there:
     


    The Add Network Location wizard will start. The whole point of this wizard is to create a network shortcut (network location) that you can use later to connect to GoodReader and to transfer files. Skip the introduction page:
     


    Select the Choose a custom network location item in the list:
     


    Enter your iPhone's IP-address taken from Step 5 of 
    WiFi File Transfer manual. Enter it exactly as you see it on GoodReader's WiFi-transfer page, with http:// and :8080 parts:
     


    Keep the default name for the network location (network shortcut) suggested by the wizard:
     


    Finish the wizard:
     
  • when the wizard will close, the network folder will open:
     


    This is the folder with all files that are stored inside GoodReader on your iPhone/iPod. Use this folder the same way you use a normal Windows folder - drag-and-drop files there, copy, move, rename, delete, create subfolders, etc.
  • only when you're completely done with file transfer, close GoodReader's WiFi-transfer page
  • the Map Network Drive wizard dialog will stay on the screen at that moment - just close it, don't enter anything there:
     
  • the network shortcut (network location) you've created will be located in the Computer window:
     


    Use it every time you need to connect to GoodReader. But if the IP-address of your iPhone changes, you have to create a new shortcut (new network location) for a new IP-address using the same procedure.
  • please do NOT assume that the IP-address is the same as it was when you were connecting the last time - IP-addresses change periodically, check it every time when connecting

GoodReader User Manual

GoodReader User Manual

Use your local WiFi-network to transfer files from your desktop computer to GoodReader.

Please note that WiFi-networking can sometimes be tricky, there are some hidden options that can prevent normal networking. Should you have any difficulties, please consult our Troubleshooting guide or contact our friendly and experienced customer support service.

Preparation steps
(must be performed the first time only, no need to do it every time)
Step 1. Make sure you have your own local WiFi network ready.
 

Step 2. Connect your computer to your WiFi network.
 

Step 3. Connect your iPhone / iPod touch to your WiFi network.
 

hide details

 Start the Settings app on your iPhone / iPod touch:
     
 
Go to Wi-Fi section. Turn the Wi-Fi switch on, if it's off. Find your network (to which your computer is connected, or which is hosted by your computer) in the list, select it, and enter the password for this network, if needed. It isvery important to ensure that you're entering the password correctly, because sometimes, if the password is incorrect, it may look like you're connected to a network, but no actual file transfer will happen. The checkmark should appear against your network name:
     
 
Wait for the WiFi antenna logo to appear at the top of the screen. It may take some time, during which your iPhone registers within the network, so just wait for antenna to appear.
 
Actual Transfer
(must be performed every time)
Step 4. Start GoodReader app on your iPhone / iPod touch.
 

Step 5. Open GoodReader's WiFi-transfer page, keep it open all the time while transferring, note the IP-address on this page (you gonna need it in Step 6).
 

hide details

 For security reasons and to save your battery power transfer is allowed only when you're on the WiFi-transfer page. You can open this page with this button on the main screen of GoodReader:
     
 
This button brings up the WiFi-transfer page:
     
 
The important things here are:
  • antenna logo at the top, it should indicate a strong WiFi signal (if you don't see this logo, then you're not connected to WiFi network - go back to Steps 1 and 3)
  • WiFi status: ON (if it's OFF, then you're not connected to WiFi network - go back to Steps 1 and 3)
  • IP-address (if you don't see it, then you're not connected to WiFi network - go back to Steps 1 and 3)
Note the IP-address, you will use it to initiate a connection from your computer.
 
IMPORTANT: IP-addresses change from time to time, even if nothing else changes in your setup. So please don't assume that the IP-address is the same as it was during your last transfer session, check this address every time when connecting.

Step 6. Choose the transfer method and do the actual transfer.
 

hide details

 
"Easy" transfer
(just a couple of files to transfer)
"Professional" transfer
(many files and folders to transfer)
Transfer by connecting your iPhone/iPod to your computer as a network folder:
 

Step 7. After all the transfer is completely done, close WiFi-transfer page.

Step 6
"Professional" transfer - connecting your iPhone as a network folder

This technique connects your iPhone to your desktop computer as a network folder. It creates a network folder shortcut, which you can use later to connect.

Connecting your iPhone to Windows Vista or Windows 7:

  • on Windows Vista or Windows 7 computer open the Start menu and select Computer:
     
  • find the toolbar at the top of Computer window and click Map network drive:
     
  • the dialog window will open. Do NOT enter anything in that dialog. Instead, click the Connect to a Web site that you can use to store your documents and pictures link there:
     


    The Add Network Location wizard will start. The whole point of this wizard is to create a network shortcut (network location) that you can use later to connect to GoodReader and to transfer files. Skip the introduction page:
     


    Select the Choose a custom network location item in the list:
     


    Enter your iPhone's IP-address taken from Step 5 of 
    WiFi File Transfer manual. Enter it exactly as you see it on GoodReader's WiFi-transfer page, with http:// and :8080 parts:
     


    Keep the default name for the network location (network shortcut) suggested by the wizard:
     


    Finish the wizard:
     
  • when the wizard will close, the network folder will open:
     


    This is the folder with all files that are stored inside GoodReader on your iPhone/iPod. Use this folder the same way you use a normal Windows folder - drag-and-drop files there, copy, move, rename, delete, create subfolders, etc.
  • only when you're completely done with file transfer, close GoodReader's WiFi-transfer page
  • the Map Network Drive wizard dialog will stay on the screen at that moment - just close it, don't enter anything there:
     
  • the network shortcut (network location) you've created will be located in the Computer window:
     


    Use it every time you need to connect to GoodReader. But if the IP-address of your iPhone changes, you have to create a new shortcut (new network location) for a new IP-address using the same procedure.
  • please do NOT assume that the IP-address is the same as it was when you were connecting the last time - IP-addresses change periodically, check it every time when connecting

The iPhone Becomes a Web Server

The iPhone Becomes a Web Server

When those Apple advertisements tout "there's an app for just about anything," they aren't kidding. The latest example? A new iPhone application which just debuted in Japan's App Store transforms the handheld into a full-blown web server. Called "ServersMan@iPhone", the application allows your iPhone to appear just like any other web server on the internet.

The new application was developed by a Japanese operation called FreeBit, a Tokyo-based venture company known for providing its network platform to many VNO/ISPs (virtual network operator/Internet service providers).

Once the app is installed, PCs on the internet can access the iPhone to upload or download files through a browser or they can use the webDAV protocol. If the PC and the iPhone are on the same network, the PC can connect directly. If they are on separate networks, then FreeBit's VPN software will engage the connection.

serversman.png

The name "ServersMan" is said to be inspired by Sony's "WalkMan," and its no coincidence that FreeBit has invited Sony's former CEO Nobuyuki Idei to be a business advisor for the company.

At the moment, the ServersMan@iPhone is only available in the Japanese App Store, but an English version is coming in March. A port for Windows Mobile devices is also under development.