From patchwork Thu Apr 14 13:31:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 65822 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp601660qge; Thu, 14 Apr 2016 06:32:05 -0700 (PDT) X-Received: by 10.107.184.8 with SMTP id i8mr16213262iof.96.1460640725694; Thu, 14 Apr 2016 06:32:05 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id ay1si4054068igc.83.2016.04.14.06.32.05; Thu, 14 Apr 2016 06:32:05 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id BD0B168576; Thu, 14 Apr 2016 13:32:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 1DC926750E; Thu, 14 Apr 2016 13:31:55 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A8F6668570; Thu, 14 Apr 2016 13:31:52 +0000 (UTC) Received: from mail-lf0-f52.google.com (mail-lf0-f52.google.com [209.85.215.52]) by lists.linaro.org (Postfix) with ESMTPS id 8B88F674D0 for ; Thu, 14 Apr 2016 13:31:50 +0000 (UTC) Received: by mail-lf0-f52.google.com with SMTP id c126so108794256lfb.2 for ; Thu, 14 Apr 2016 06:31:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xG6Eb3nP/4NFqiyS+et00RfZPdExNqdklYOcwvy9p9Q=; b=W2L2cwFJbv2EjqYoZ5YO6C+Wny+FucNj1FbsI2BUtYp/BwSjVxOXXe0ZtV166DByDW IJU6Z/+xFG4ieD4anwlByoNbmGxei8psid7AoGIqIjT1iMoLFPDj1sgfimFET0j2p+3r 332MV5YlsejrUlINiwxCuspx/b0GSmki/3cd636krHpolbUJXcvYjWXYDrAT0sx1fF5P LCL4/+qv/d5GQSsAntKue7kk8SVB2zZ+GKhFS7Df6rqD6DX3VMHQAik2k5w0gdpo/v1n 7gRNTFkor4v4+0cErEFEWDp5W4M5R1EOuhQfCyjJAHIU5KziCZ9woIT5GMAu8vYyg+CS kEsw== X-Gm-Message-State: AOPr4FXGCzhjhgZ/Kl57Hj7AfTMn5koACf7DJr/QRXvTccqY1JdooXedW+c0XzVi4O/6WbErUYs= X-Received: by 10.112.181.196 with SMTP id dy4mr6462270lbc.42.1460640709374; Thu, 14 Apr 2016 06:31:49 -0700 (PDT) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id g199sm6893315lfe.30.2016.04.14.06.31.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Apr 2016 06:31:48 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 14 Apr 2016 16:31:43 +0300 Message-Id: <1460640703-18710-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: timers patch Subject: [lng-odp] [API-NEXT PATCH v2] doc/users-quide: correct timer API section X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Ivan Khoronzhuk --- v2..v1: - just rebased with several not important corrections doc/users-guide/users-guide.adoc | 50 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/doc/users-guide/users-guide.adoc b/doc/users-guide/users-guide.adoc index a2e5058..69b1930 100644 --- a/doc/users-guide/users-guide.adoc +++ b/doc/users-guide/users-guide.adoc @@ -335,11 +335,51 @@ The +odp_time_t+ opaque type represents local or global timestamps. === Timer Timers are how ODP applications measure and respond to the passage of time. -Timers are drawn from specialized pools called timer pools that have their -own abstract type (+odp_timer_pool_t+). Applications may have many timers -active at the same time and can set them to use either relative or absolute -time. When timers expire they create events of type +odp_timeout_t+, which -serve as notifications of timer expiration. +The timer API is supposed to be used when time synchronization with events is +needed and has different nature than time API has. Usually, timers require a +separate h/w module to be used for generating timeouts. Timers are drawn from +specialized pools called timer pools that have their own abstract type +(+odp_timer_pool_t+). Applications may have many timers active at the same +time and can set them to use either relative or absolute time. When timers +expire they create events of type +odp_timeout_t+, which serve as notifications +of timer expiration. The event is placed on a queue pointed while timer +allocation. + +Each timer pool can be set with it's own resolution in ns and number of +supported timers. So, timer pool can be considered as a time source with +it's own resolution and defined number of timers. All timers in timer pool +are handled with same time source with same resolution. If user needs two types +of timers with different requirements for resolution then better to create +two pools with it's own resolution, it can decrease load on hardware. + +An expiration time for the timer is set in it's own ticks, so nanoseconds have +to be converted first with conversation function +odp_timer_ns_to_tick()+, to +convert it back to ns use +odp_timer_tick_to_ns()+. Both functions require +to pass a timer pool used, as it can be sourced with it's own time source that +can have specific resolution and thus different conversion ratio. + +To set a timer to deliver a timeout event the two functions can be used: ++odp_timer_set_abs()+ and +odp_timer_set_rel()+. Both of them require an +event to be passed and a time interval in ticks of corresponding timer pool. +The expiration time for a timer can be set based on current tick value for +a timer pool taken with +odp_timer_current_tick()+, to set a timer +(absolute time) with a user-provided timeout event, the +odp_timer_set_abs()+ +can be used. An event is the event converted from timeout allocated from timeout +pool with +odp_timeout_alloc()+. The event is returned to timer queue when set +time interval has expired and can be also converted to timeout with ++odp_timeout_from_event()+, if it's needed. To free timeout the ++odp_timeout_free()+ can be used, if it's presented as event it can be freed +as event with +odp_event_free()+. + +In general, timer pool characterizes time source, and timer is characterized +with timer pool, user pointer and destination queue for delivering. The timeout +is characterized with timer, timer pool and time of expiration and is placed to +queue set while timer allocation. The timeout can be delivered only to the +destination queue of concrete timer. To get a timer generated a timeout ++odp_timeout_timer()+ can be used. + +When timer is freed it's returned to timer pool and is ready to be allocated +once again. A timer can be canceled with odp_timer_cancel. === Synchronizer Multiple threads operating in parallel typically require various