On Fri, 2 Sep 2011, Daniel B?nzli wrote:

> Hello,
> 
> Can anybody confirm me that the following code works on cygwin :
> 
> let cpu_count () =
>   try match Sys.os_type with
>   | "Win32" -> int_of_string (Sys.getenv "NUMBER_OF_PROCESSORS")
>   | _ ->
>       let i = Unix.open_process_in "getconf _NPROCESSORS_ONLN" in
>       let close () = ignore (Unix.close_process_in i) in
>       try Scanf.fscanf i "%d" (fun n -> close (); n) with e -> close (); 
> raise e
>   with
>   | Not_found | Sys_error _ | Failure _ | Scanf.Scan_failure _
>   | End_of_file | Unix.Unix_error (_, _, _) -> 1
> 
> Thanks,
> 

http://repo.or.cz/w/apc.git/blob/55de75ccb853f5e4443fd484e5eb95e1342e72bd:/ml_apc.c

has code to get number of cpus for linux/windows/solaris and osx

-- 
mailto:[email protected]

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to