From owner-freebsd-questions@FreeBSD.ORG Wed Mar 17 19:16:51 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38CA6106566C for ; Wed, 17 Mar 2010 19:16:51 +0000 (UTC) (envelope-from amvandemore@gmail.com) Received: from mail-pw0-f54.google.com (mail-pw0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 0B86C8FC0A for ; Wed, 17 Mar 2010 19:16:50 +0000 (UTC) Received: by pwj4 with SMTP id 4so1154590pwj.13 for ; Wed, 17 Mar 2010 12:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=7tIziuJJjzrWNR+kZKHHKYnU9H2WNipEWWavag7ElUA=; b=JlBdKKvlf57adIZ+dPswL4qsvM5QO/nh6vyNSlprr8umkql3N1vssZvaT5FQh3bUjP kdNUhp9capkdLeMKfOYFpT1dKo1ILYw229PWjsHfPPVNmNzQtOMd1F54aBrSdGNrFGl7 aDZGq0YdKP5zME/zI/fBj+0Fc3kaNY2EQ1DEY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=h8uP5BlhQXxpbIqlJ4ZFVGumbyDvonY1bLMgBBiMcXv1ZPdxGUME+cZEOrnbmiMG0i X387r8yoUXkClQ7DhYDPDw/Cc1bCPuOc+DP5QqS2MWrOHvSvIsYxmRjCWpmtzukFk0vT 551sKHDXHc90pspEIV7ZrdvSFDGCYN9ZGP3WE= MIME-Version: 1.0 Received: by 10.142.67.34 with SMTP id p34mr488007wfa.335.1268853408527; Wed, 17 Mar 2010 12:16:48 -0700 (PDT) In-Reply-To: References: <10E075E52DED228526F5ECAB@utd65257.utdallas.edu> <4BA10BEA.1060303@wallnet.com> Date: Wed, 17 Mar 2010 14:16:48 -0500 Message-ID: <6201873e1003171216q40e102dev23b6059f22e92b8@mail.gmail.com> From: Adam Vande More To: "Zepeda, Herbey" Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-questions@freebsd.org Subject: Re: multicore processing question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Mar 2010 19:16:51 -0000 On Wed, Mar 17, 2010 at 1:02 PM, Zepeda, Herbey wrote: > Hi, > > I'm relatively new to FreeBSD and have had a hard time get to the right > information relating multicore processing. I hope someone can give me some > pointers. > > I have a two core processor and FreeBSD (latest stable release). > > Question: > > If I have a c program that creates child processes with fork and exec (in a > non blocking way), will the child processes be executed by FreeBSD in > parallel using the different cores without me having to do special > synchronization arrangements to my program? > Well probably...processes are automatically on SMP kernels so a basic example is if you have 2 cores and 2 processes which are each utilizing 100% of cpu time, then each process would be assigned to a separate core. However in practice executions states are much more complicated and both processes may be assigned to a single core under certain conditions eg one is in a sleep state. The short story is this is all handled automatically, and many applications run just fine without any further tweaking > Will I need threads instead of processes? > Really depends on your need, but in general properly creating threaded safe applications is significantly harder(at least to my understanding, I don't do it). If you need to use this route, you can check out http://www.osnews.com/story/22152/Apple_Releases_Grand_Central_Dispatch_as_Open_Source It's available on FreeBSD. -- Adam Vande More