Dec 12, 2019 Apps that let you schedule downloads on Mac. Scheduling your downloads makes the downloading experience so much more relaxing and enjoyable. Such option gives you more control over time and traffic cost and can download your files at nighttime or when you are away from the computer. The above screenshot displays the new Task Window of this Scheduler App for Mac OS X. Note in the above screenshot that multiple dates have been selected with the help of shift key on the keyboard, also note that the time of task execution can be selected by moving the hour and minute hands of the analog clock in the new schedule task window.
Energy Efficiency and the User Experience
All apps consume energy—whenever they update the user interface, perform networking operations, write to disk, or run code on the CPU. As users rely increasingly on battery power—and as apps proliferate—energy efficiency becomes integral to the user experience.
A great user experience requires:
Great battery life. As energy efficiency goes down, so does battery life. Users want all-day battery life on their portable devices.
Awesome speed. OS X is designed to provide great performance during complex operations—and to make your app fly.
Responsiveness. Too many resources being consumed at once can result in a laggy interface that’s slow to respond to user input.
Cool, quiet system. As more apps use more resources, the system works harder and faster, and the physical temperature of a device gradually rises. When this occurs, the system takes steps to cool down to a more acceptable level. On devices with fans, those fans may become active and audible to the user.
OS X Energy-Saving Technologies
OS X employs advanced energy-saving technologies that help users get the most out of their Macs. These features help the system make smart decisions about how to utilize resources and run code as efficiently as possible.
Centralized Task Scheduling and Grand Central Dispatch
Intensive background operations, such as software updates or file backups, may be unavoidable. Centralized Task Scheduling (CTS) and Grand Central Dispatch (GCD) APIs let you designate criteria that indicate when and how often a task should be deferred, how long it can be deferred, and under what circumstances. The system then makes an intelligent decision about when to perform the task based on the specified criteria.
Quality of Service Levels
Tasks that affect the user, such as downloading and playing music, take priority over background and discretionary work. Quality of service class APIs allow you to assign distinct priority levels to the work your app performs, giving you fine grained control over task prioritization.
Event-Based APIs and Services
Timers deliver events, or fire, at prescribed time intervals. If a timer fires when the system is idle, the CPU and numerous other systems are awakened from their low-power states. Yet many of these systems aren’t always needed to perform the work invoked by the timer. If the work can be performed when the system hardware is already running, the additional cost is not incurred and the CPU can remain idle longer. OS X provides services and APIs that efficiently deliver events without unnecessarily waking the CPU.
App Nap
Mac Os X Ios Download
When your app isn’t busy performing user-initiated work, the system may put your app in App Nap. App Nap conserves energy by regulating your app’s CPU usage, I/O, and timers. As soon as the user resumes interacting with your app, OS X switches it back to full speed. Transitions are so seamless that the user thinks your app has been running at full speed all along. You can enhance App Nap by implementing notifications that tell your app when it becomes inactive, so it can immediately start reducing activity.
Battery Menu, Activity Monitor, and Developer Tools
The Battery Status menu and Activity Monitor let you quickly identify apps that are using significant amounts of energy in OS X. Xcode, Instruments, and numerous command-line tools help you identify and address energy problems as you develop your app, rather than after those problems are encountered by users.
Your Obligation as a Developer
Even small inefficiencies in apps add up across the system, significantly affecting battery life, performance, responsiveness, and temperature. As an app developer, you have an obligation to make sure your app runs as efficiently as possible. Use recommended APIs so the system can make smart decisions about how best to manage your app and the resources it uses. Whenever possible, avoid unnecessary updates to the user interface and I/O. Power-intensive operations should be under the user’s control. If a user initiates a large iMovie render, Automator batch job, Compressor conversion, or Xcode compile, for example, the user should not be surprised if the activity consumes power. Strive to make your app absolutely idle when it is not responding to user input.
By adhering to recommended guidelines, you can make big contributions to the overall energy efficiency of the platform and the satisfaction of your users.
Copyright © 2018 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2016-09-13
OS X is based on Mach and BSD. Like Mach and most BSD UNIX systems, it contains an advanced scheduler based on the CMU Mach 3 scheduler. This chapter describes the scheduler from the perspective of both a kernel programmer and an application developer attempting to set scheduling parameters.
This chapter begins with the Overview of Scheduling, which describes the basic concepts behind Mach scheduling at a high level, including real-time priority support.
The second section, Using Mach Scheduling From User Applications, describes how to access certain key Mach scheduler routines from user applications and from other parts of the kernel outside the scheduler.
The third section, Kernel Thread APIs, explains scheduler-related topics including how to create and terminate kernel threads and describes the BSD
spl
macros and their limited usefulness in OS X.Overview of Scheduling
The OS X scheduler is derived from the scheduler used in OSFMK 7.3. In general, much documentation about prior implementations applies to the scheduler in OS X, although you will find numerous differences. The details of those differences are beyond the scope of this overview.
Mach scheduling is based on a system of run queues at various priorities that are handled in different ways. The priority levels are divided into four bands according to their characteristics, as described in Table 10-1.
Priority Band | Characteristics |
---|---|
Normal | normal application thread priorities |
System high priority | threads whose priority has been raised above normal threads |
Kernel mode only | reserved for threads created inside the kernel that need to run at a higher priority than all user space threads (I/O Kit workloops, for example) |
Real-time threads | threads whose priority is based on getting a well-defined fraction of total clock cycles, regardless of other activity (in an audio player application, for example). |
Threads can migrate between priority levels for a number of reasons, largely as an artifact of the time sharing algorithm used. However, this migration is within a given band.
Threads marked as being real-time priority are also special in the eyes of the scheduler. A real-time thread tells the scheduler that it needs to run for
A
cycles out of the next B
cycles. For example, it might need to run for 3000 out of the next 7000 clock cycles in order to keep up. It also tells the scheduler whether those cycles must be contiguous. Using long contiguous quanta is generally frowned upon but is occasionally necessary for specialized real-time applications.The kernel will make every effort to honor the request, but since this is soft real-time, it cannot be guaranteed. In particular, if the real-time thread requests something relatively reasonable, its priority will remain in the real-time band, but if it lies blatantly about its requirements and behaves in a compute-bound fashion, it may be demoted to the priority of a normal thread.
Changing a thread’s priority to turn it into a real-time priority thread using Mach calls is described in more detail in Using Mach Scheduling From User Applications.
In addition to the raw Mach RPC interfaces, some aspects of a thread’s priority can be controlled from user space using the POSIX thread priority API. The POSIX thread API is able to set thread priority only within the lowest priority band (0–63). For more information on the POSIX thread priority API, see Using the pthreads API to Influence Scheduling.
Why Did My Thread Priority Change?
There are many reasons that a thread’s priority can change. This section attempts to explain the root cause of these thread priority changes.
A real-time thread, as mentioned previously, is penalized (and may even be knocked down to normal thread priority) if it exceeds its time quantum without blocking repeatedly. For this reason, it is very important to make a reasonable guess about your thread’s workload if it needs to run in the real-time band.
Threads that are heavily compute-bound are given lower priority to help minimize response time for interactive tasks so that high–priority compute–bound threads cannot monopolize the system and prevent lower–priority I/O-bound threads from running. Even at a lower priority, the compute–bound threads still run frequently, since the higher–priority I/O-bound threads do only a short amount of processing, block on I/O again, then allow the compute-bound threads to execute.
All of these mechanisms are operating continually in the Mach scheduler. This means that threads are frequently moving up or down in priority based upon their behavior and the behavior of other threads in the system.
Using Mach Scheduling From User Applications
There are three basic ways to change how a user thread is scheduled. You can use the BSD
pthreads
API to change basic policy and importance. You can also use Mach RPC calls to change a task’s importance. Finally, you can use RPC calls to change the scheduling policy to move a thread into a different scheduling band. This is commonly used when interacting with CoreAudio.The
pthreads
API is a user space API, and has limited relevance for kernel programmers. The Mach thread and task APIs are more general and can be used from anywhere in the kernel. The Mach thread and task calls can also be called from user applications.Using the pthreads
API to Influence Scheduling
OS X supports a number of policies at the POSIX threads API level. If you need real-time behavior, you must use the Mach
thread_policy_set
call. This is described in Using the Mach Thread API to Influence Scheduling.The
pthreads
API adjusts the priority of threads within a given task. It does not necessarily impact performance relative to threads in other tasks. To increase the priority of a task, you can use nice
or renice
from the command line or call getpriority
and setpriority
from your application.The API provides two functions:
pthread_getschedparam
and pthread_setschedparam
. Their prototypes look like this:The arguments for
pthread_getschedparam
are straightforward. The first argument is a thread ID, and the others are pointers to memory where the results will be stored.The arguments to
pthread_setschedparam
are not as obvious, however. As with pthread_getschedparam
, the first argument is a thread ID.The second argument to
pthread_setschedparam
is the desired policy, which can currently be one of SCHED_FIFO
(first in, first out), SCHED_RR
(round-robin), or SCHED_OTHER
. The SCHED_OTHER
policy is generally used for extra policies that are specific to a given operating system, and should thus be avoided when writing portable code.The third argument is a structure that contains various scheduling parameters.
Here is a basic example of using
pthreads
functions to set a thread’s scheduling policy and priority.This code snippet sets the scheduling policy for the current thread to round-robin scheduling, and sets the thread’s relative importance within the task to the value passed in through the
priority
argument.For more information, see the manual page for
pthread
.Using the Mach Thread API to Influence Scheduling
This API is frequently used in multimedia applications to obtain real-time priority. It is also useful in other situations when the
pthread
scheduling API cannot be used or does not provide the needed functionality.The API consists of two functions,
thread_policy_set
and thread_policy_get
.The parameters of these functions are roughly the same, except that the
thread_policy_get
function takes pointers for the count
and the get_default
arguments. The count is an inout
parameter, meaning that it is interpreted as the maximum amount of storage (in units of int32_t
) that the calling task has allocated for the return, but it is also overwritten by the scheduler to indicate the amount of data that was actually returned.These functions get and set several parameters, according to the thread policy chosen. The possible thread policies are listed in Table 10-2.
Policy | Meaning |
---|---|
THREAD_STANDARD_POLICY | Default value |
THREAD_TIME_CONSTRAINT_POLICY | Used to specify real-time behavior. |
THREAD_PRECEDENCE_POLICY | Used to indicate the importance of computation relative to other threads in a given task. |
The following code snippet shows how to set the priority of a task to tell the scheduler that it needs real-time performance. The example values provided in comments are based on the estimated needs of
esd
(the Esound daemon).The time values are in terms of Mach absolute time units. Since these values differ on different CPUs, you should generally use numbers relative to HZ (a global variable in the kernel that contains the current number of ticks per second). You can either handle this conversion yourself by dividing this value by an appropriate quantity or use the conversion routines described in Using Kernel Time Abstractions .
Say your computer reports 133 million for the value of HZ. If you pass the example values given as arguments to this function, your thread tells the scheduler that it needs approximately 40,000 (HZ/3300) out of the next 833,333 (HZ/160) bus cycles. The
preemptible
value (1) indicates that those 40,000 bus cycles need not be contiguous. However, the constraint
value (HZ/2200) tells the scheduler that there can be no more than 60,000 bus cycles between the start of computation and the end of computation.Note: Because the constraint sets a maximum bound for computation, it must be larger than the value for computation.
A straightforward example using this API is code that displays video directly to the framebuffer hardware. It needs to run for a certain number of cycles every frame to get the new data into the frame buffer. It can be interrupted without worry, but if it is interrupted for too long, the video hardware starts displaying an outdated frame before the software writes the updated data, resulting in a nasty glitch. Audio has similar behavior, but since it is usually buffered along the way (in hardware and in software), there is greater tolerance for variations in timing, to a point.
Another policy call is
THREAD_PRECEDENCE_POLICY
. This is used for setting the relative importance of non-real-time threads. Its calling convention is similar, except that its structure is thread_precedence_policy
, and contains only one field, an integer_t
called importance
. While this is a signed 32-bit value, the minimum legal value is zero (IDLE_PRI
). threads set to IDLE_PRI
will only execute when no other thread is scheduled to execute.In general, larger values indicate higher priority. The maximum limit is subject to change, as are the priority bands, some of which have special purposes (such as real-time threads). Thus, in general, you should use pthreads APIs to achieve this functionality rather than using this policy directly unless you are setting up an idle thread.
Using the Mach Task API to Influence Scheduling
This relatively simple API is not particularly useful for most developers. However, it may be beneficial if you are developing a graphical user interface for Darwin. It also provides some insight into the prioritization of tasks in OS X. It is presented here for completeness.
The API consists of two functions,
task_policy_set
and task_policy_get
.As with
thread_policy_set
and thread_policy_get
, the parameters are similar, except that the task_policy_get
function takes pointers for the count
and the get_default
arguments. The count
argument is an inout
parameter. It is interpreted as the maximum amount of storage that the calling task has allocated for the return, but it is also overwritten by the scheduler to indicate the amount of data that was actually returned.These functions get and set a single parameter, that of the role of a given task, which changes the way the task’s priority gets altered over time. The possible roles of a task are listed in Table 10-3.
Role | Meaning |
---|---|
TASK_UNSPECIFIED | Default value |
TASK_RENICED | This is set when a process is executed with nice or is modified by renice . |
TASK_FOREGROUND_APPLICATION | GUI application in the foreground. There can be more than one foreground application. |
TASK_BACKGROUND_APPLICATION Press Ctrl+F, and then type your search words.If an action that you use often does not have a shortcut key, you can to create one.If you are using Microsoft Word Starter, be aware that not all the features listed for Word are supported in Word Starter. Notes:.To quickly find a shortcut in this article, you can use Search. For example, press Alt+H to open the Home tab, and Alt+Q to move to the Tell me or Search field. Mac app to create short keys youtube. Note: Add-ins and other programs may add new tabs to the ribbon and may provide access keys for those tabs.You can combine the Key Tips letters with the Alt key to make shortcuts called Access Keys for the ribbon options. | GUI application in the background. |
TASK_CONTROL_APPLICATION | Reserved for the dock or equivalent (assigned FCFS). |
TASK_GRAPHICS_SERVER | Reserved for WindowServer or equivalent (assigned FCFS). |
The following code snippet shows how to set the priority of a task to tell the scheduler that it is a foreground application (regardless of whether it really is).
Kernel Thread APIs
The OS X scheduler provides a number of public APIs. While many of these APIs should not be used, the APIs to create, destroy, and alter kernel threads are of particular importance. While not technically part of the scheduler itself, they are inextricably tied to it.
The scheduler directly provides certain services that are commonly associated with the use of kernel threads, without which kernel threads would be of limited utility. For example, the scheduler provides support for wait queues, which are used in various synchronization primitives such as mutex locks and semaphores.
Creating and Destroying Kernel Threads
The recommended interface for creating threads within the kernel is through the I/O Kit. It provides
IOCreateThread
, IOThreadSelf
, and IOExitThread
functions that make it relatively painless to create threads in the kernel.The basic functions for creating and terminating kernel threads are:
With the exception of
IOCreateThread
(which is a bit more complex), the I/O Kit functions are fairly thin wrappers around Mach thread functions. The types involved are also very thin abstractions. IOThread
is really the same as thread_t
.The
IOCreateThread
function creates a new thread that immediately begins executing the function that you specify. It passes a single argument to that function. If you need to pass more than one argument, you should dynamically allocate a data structure and pass a pointer to that structure.For example, the following code creates a kernel thread and executes the function
myfunc
in that thread:One other useful function is
thread_terminate
. This can be used to destroy an arbitrary thread (except, of course, the currently running thread). This can be extremely dangerous if not done correctly. Before tearing down a thread with thread_terminate
, you should lock the thread and disable any outstanding timers against it. If you fail to deactivate a timer, a kernel panic will occur when the timer expires.With that in mind, you may be able to terminate a thread as follows:
There thread is of type
thread_t
. In general, you can only be assured that you can kill yourself, not other threads in the system. The function thread_terminate
takes a single parameter of type thread_act_t
(a thread activation). The function getact_thread
takes a thread shuttle (thread_shuttle_t
) or thread_t
and returns the thread activation associated with it.SPL
and Friends
BSD–based and Mach–based operating systems contain legacy functions designed for basic single-processor synchronization. These include functions such as
splhigh
, splbio
, splx
, and other similar functions. Since these functions are not particularly useful for synchronization in an SMP situation, they are not particularly useful as synchronization tools in OS X.If you are porting legacy code from earlier Mach–based or BSD–based operating systems, you must find an alternate means of providing synchronization. In many cases, this is as simple as taking the kernel or network funnel. In parts of the kernel, the use of
spl
functions does nothing, but causes no harm if you are holding a funnel (and results in a panic if you are not). In other parts of the kernel, spl
macros are actually used. Because spl
cannot necessarily be used for its intended purpose, it should not be used in general unless you are writing code it a part of the kernel that already uses it. You should instead use alternate synchronization primitives such as those described in Synchronization Primitives.Best Mac Os X Apps
Wait Queues and Wait Primitives
The wait queue API is used extensively by the scheduler and is closely tied to the scheduler in its implementation. It is also used extensively in locks, semaphores, and other synchronization primitives. The wait queue API is both powerful and flexible, and as a result is somewhat large. Not all of the API is exported outside the scheduler, and parts are not useful outside the context of the wait queue functions themselves. This section documents only the public API.
The wait queue API includes the following functions:
Most of the functions and their arguments are straightforward and are not presented in detail. However, a few require special attention.
Most of the functions take an event_t as an argument. These can be arbitrary 32-bit values, which leads to the potential for conflicting events on certain wait queues. The traditional way to avoid this problem is to use the address of a data object that is somehow related to the code in question as that 32-bit integer value.
![Scheduling App Mac Os X Scheduling App Mac Os X](/uploads/1/2/6/0/126012717/841805608.jpg)
For example, if you are waiting for an event that indicates that a new block of data has been added to a ring buffer, and if that ring buffer’s head pointer was called
rb_head
, you might pass the value &rb_head
as the event ID. Because wait queue usage does not generally cross address space boundaries, this is generally sufficient to avoid any event ID conflicts.Notice the functions ending in
_locked
. These functions require that your thread be holding a lock on the wait queue before they are called. Functions ending in _locked
are equivalent to their nonlocked counterparts (where applicable) except that they do not lock the queue on entry and may not unlock the queue on exit (depending on the value of unlock
). The remainder of this section does not differentiate between locked and unlocked functions.The
wait_queue_alloc
and wait_queue_init
functions take a policy parameter, which can be one of the following:SYNC_POLICY_FIFO
—first-in, first-outSYNC_POLICY_FIXED_PRIORITY
—policy based on thread prioritySYNC_POLICY_PREPOST
—keep track of number of wakeups where no thread was waiting and allow threads to immediately continue executing without waiting until that count reaches zero. This is frequently used when implementing semaphores.This includes monitoring and alert systems that promptly alert you when the market moves against you. FXCM provides a powerful yet user-friendly trading platform that is a great choice for Mac users. With this platform, you will easily maintain your equity above a set limit thus sound trading practices.With an easy to understand interface, FXCM will not disappoint.The five described above are the best forex trading platform for Mac OS. This platform can also be available on the go through iPhone and iPad apps.
You should not use the
wait_queue_init
function outside the scheduler. Because a wait queue is an opaque object outside that context, you cannot determine the appropriate size for allocation. Thus, because the size could change in the future, you should always use wait_queue_alloc
and wait_queue_free
unless you are writing code within the scheduler itself.Similarly, the functions
wait_queue_member
, wait_queue_member_locked
, wait_queue_link
, wait_queue_unlink
, and wait_queue_unlink_one
are operations on subordinate queues, which are not exported outside the scheduler.The function
wait_queue_member
determines whether a subordinate queue is a member of a queue.The functions
wait_queue_link
and wait_queue_unlink
link and unlink a given subordinate queue from its parent queue, respectively.The function
wait_queue_unlink_one
unlinks the first subordinate queue in a given parent and returns it.The function
wait_queue_assert_wait
causes the calling thread to wait on the wait queue until it is either interrupted (by a thread timer, for example) or explicitly awakened by another thread. The interruptible
flag indicates whether this function should allow an asynchronous event to interrupt waiting.The function
wait_queue_wakeup_all
wakes up all threads waiting on a given queue for a particular event.The function
wait_queue_peek_locked
returns the first thread from a given wait queue that is waiting on a given event. It does not remove the thread from the queue, nor does it wake the thread. It also returns the wait queue where the thread was found. If the thread is found in a subordinate queue, other subordinate queues are unlocked, as is the parent queue. Only the queue where the thread was found remains locked.The function
wait_queue_pull_thread_locked
pulls a thread from the wait queue and optionally unlocks the queue. This is generally used with the result of a previous call to wait_queue_peek_locked
.The function
wait_queue_wakeup_identity_locked
wakes up the first thread that is waiting for a given event on a given wait queue and starts it running but leaves the thread locked. It then returns a pointer to the thread. This can be used to wake the first thread in a queue and then modify unrelated structures based on which thread was actually awakened before allowing the thread to execute.The function
wait_queue_wakeup_one
wakes up the first thread that is waiting for a given event on a given wait queue.The function
wait_queue_wakeup_thread
wakes up a given thread if and only if it is waiting on the specified event and wait queue (or one of its subordinates).The function
wait_queue_remove
wakes a given thread without regard to the wait queue or event on which it is waiting.Scheduling App Mac Os X
Best Mac Os Apps
Mac Os App Store
Copyright © 2002, 2013 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2013-08-08